https://downloads.mysql.com
cd mysql-5.6.36 cmake . -DCMAKE_INSTALL_PREFIX=/data/mysql-5.6.36 \ -DMYSQL_DATADIR=/data/mysql-5.6.36/data \ -DMYSQL_UNIX_ADDR=/data/mysql-5.6.36/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS=all \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ -DWITH_ZLIB=bundled \ -DWITH_SSL=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DENABLE_DOWNLOADS=1 \ -DWITH_DEBUG=0 make && make install ln -s /data/mysql-5.6.36/ /data/mysql
[root@db2 mysql]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.6.36 Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
数据库的启动流程
mysql.server ------>mysqld_safe------->mysqld
启动: [root@db02 ~]# /etc/init.d/mysqld start 或者: [root@db02 ~]# /data/mysql/bin/mysqld_safe & 关闭: [root@db02 ~]# mysqladmin -uroot -p123456 shutdown 或者: [root@db02 ~]# /etc/init.d/mysqld stop
① mysql root 密码为空时的设置
/application/mysql/bin/mysqladmin -uroot password "123456" /application/mysql/bin/mysql -uroot -poldboy123mysqladmin -u root -p112233 password '123456'; mysqladmin -uroot -pold_pwd password "new_pwd"
② 登录mysql再设置
mysql> use mysql Database changed mysql> set password for root@localhost=password("123123"); Query OK, 0 rows affected (0.00 sec)
③ 登录mysql再设置
mysql> use mysql Database changed mysql> update user set password=password("123456") where user='root' and host='localhost'; Query OK, 1 row affected (0.00 sec)
yum安装 源码安装 二进制安装
mysql_install_db 是初始化的命令
mysql_install_db --basedir=/data/mysql/ --datadir=/data/mysql/data --user=mysql
basedir 安装路径 datadir 数据库的存放路径
转载于:https://www.cnblogs.com/augustyang/p/10901203.html
相关资源:PHP and MySQL Web Development 5th Edition 完整源代码