Linux安装MySQL。
mysql官网,我是没有找到怎么下载。所以,我上传到百度云上供大家免费下载。
使用linux的sz、rz命令可以上传,也可以使用filezila工具上传,上传完毕后,见文件如下:
这一步非常关键,保证在安装mysql之前,Linux上对mysql是干净的,否则经常会导致安装失败。
升级mysql到5.7,这篇文章中有详细介绍,可参照。
[root@iZ23gsv94suZ soft]# rpm -ivh MySQL-server-5.7.4_m14-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
find: `/var/lib/mysql': No such file or directory
1:MySQL-server ########################################### [100%]
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
tips:
no other statement but 'SET PASSWORD' will be accepted
。 rpm -ivh MySQL-client-5.7.4_m14-1.el6.x86_64.rpm
[root@iZ23gsv94suZ mysql]# service mysql start
Starting MySQL. SUCCESS!
[root@iZ23gsv94suZ mysql]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
密码在“/root/.mysql_secret”这个文件中。
mysql> use mysql
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
此时出现了错误,我们需要:
mysql> set password=password("root");
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 password=PASSWORD("lixiaoli") where user="root";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
哈哈,请不要相信我的密码是“lixiaoli”,我只不过是喜欢她而已!没错,就是李孝利。
为了保证Linux的安全期间,我们需要开启防火墙,同时,将mysql的3306端口释放出去。
请注意先关闭防火墙
service iptables stop
vim /etc/sysconfig/iptables
打开以上文件,增加如下内容:
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
service iptables save
service iptables start
mysql> grant all privileges on *.* to root@'192.168.44.11' identified by "lixiaoli";
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)