您的位置:首页 > 运维架构 > Linux

linux安装mysql

2016-01-18 15:41 453 查看
linux安装mysql。

一、安装文件

mysql官网,我是没有找到怎么下载。所以,我上传到百度云上供大家免费下载

二、安装

①、上传文件

使用Linux的sz、rz命令可以上传,也可以使用filezila工具上传,上传完毕后,见文件如下:



②、清理mysql

这一步非常关键,保证在安装mysql之前,Linux上对mysql是干净的,否则经常会导致安装失败。

升级mysql到5.7,这篇文章中有详细介绍,可参照。

③、安装MySQL-server

[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[/code] 
tips:

注意’/root/.mysql_secret’这个文件。

注意
no other statement but 'SET PASSWORD' will be accepted


④、安装MySQL-client

rpm -ivh MySQL-client-5.7.4_m14-1.el6.x86_64.rpm


五、启动mysql服务

[root@iZ23gsv94suZ mysql]# service mysql start
Starting MySQL. SUCCESS!


⑥、连接mysql

[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)


“grant all privileges”:开启所有权限,包括增删改查了!

“.”:当有数据库的数据表。

“root”:user名了!

“‘192.168.44.11’”自然就是对那一台机器开启远程权限了。

“‘lixiaoli’”:自然是对应的密码了



相关文章

Linux上更改mysql数据库目录

mysql之my.cnf

linux的crontab定时服务备份mysql数据

升级mysql到5.7


感谢您阅读【沉默王二的博客】,如果王二的博客给您带来一丝帮助或感动,我(也就是王二)将不甚荣幸。

如果您碰巧喜欢,可以留言或者私信我,这将是我鼓捣更多优秀文章的最强动力。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: