1.官網下載
查看linux是32位還是64位 file /bin/ls
下載mysql-5.7.17-linux-glibc2.5-x86_64.tar
2.安裝與配置
[root:/home/tmp # tar -xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar
mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
mysql-test-5.7.17-linux-glibc2.5-x86_64.tar.gz
[root:/home/tmp # tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
[root:/home/tmp # cd /usr/local
[root:/usr/local # mkdir mysql
[root:/usr/local # cp -rp /home/tmp/mysql .
[root:/usr/local # cd mysql/
[root:/usr/local/mysql # groupadd mysql
[root:/usr/local/mysql # useradd -g mysql mysql
[root:/usr/local # cd ..
[root:/usr/local # % chown -R mysql mysql/
[root:/usr/local # chgrp -R mysql mysql/
[root:/usr/local/mysql # cd mysql/ [root:/usr/local/mysql # bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
2017-03-17 09:34:00 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2017-03-17 09:34:07 [WARNING] The bootstrap log isn't empty:
2017-03-17 09:34:07 [WARNING] 2017-03-17T01:34:01.021294Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2017-03-17T01:34:01.022032Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2017-03-17T01:34:01.022039Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
[root:/usr/local/mysql # cp -a ./support-files/my-default.cnf /etc/my.cnf
[root:/usr/local/mysql # cp -a ./support-files/mysql.server /etc/init.d/mysqld
[root:/usr/local/mysql # cd bin
sgs1-pas1:/usr/local/mysql/bin # ./mysqld_safe --user=mysql & --安全模式
[1] 21402
sgs1-pas1:/usr/local/mysql/bin # 2017-03-17T01:35:57.584201Z mysqld_safe Logging to '/usr/local/mysql/data/sgs1-pas1.err'.
Logging to '/usr/local/mysql/data/sgs1-pas1.err'.
2017-03-17T01:35:57.677401Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2017-03-17T01:37:25.182204Z mysqld_safe mysqld from pid file /usr/local/mysql/data/sgs1-pas1.pid ended
[1]+ Done ./mysqld_safe --user=mysql
[root:/usr/local/mysql/bin #
另起一終端
[root:/usr/local/mysql/bin # /etc/init.d/mysqld restart
[root:/usr/local/mysql/bin # cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2017-03-17 09:34:01
FSe&IrLnO:5M --隨機密碼
[root:/usr/local/mysql/bin # ./mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.17
Copyright (c) 2000, 2016, 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> set PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
[mysql> flush privileges
-> ;
Query OK, 0 rows affected (0.00 sec)
[mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
[mysql> select host,user from user;
+-----------+-----------+
| host | user |
+-----------+-----------+
| % | root |
| localhost | mysql.sys |
+-----------+-----------+
2 rows in set (0.00 sec)
[mysql> exit;
Bye
[root:/usr/local/mysql/bin # /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
3.會用到的命令
rpm -qa|grep mysql 查看是否安裝mysql
whereis mysql 查找mysql
which mysql 查找mysql
用root帳號登錄後,在/etc/my.cnf 中的[mysqld]後添加添加lower_case_table_names=1,重啓MYSQL服務