CENTOS 中MYSQL的安装与使用

1.安装mysql客户端

yum install mysql

2.安装mysql服务端

yum install mysql-server

3.启动mysql服务

service mysqld start

4.登录mysql

mysql -u root -p

5.切换到mysql数据库

use mysql;

6.查看现有用户,密码及允许连接的主机

select user,password,host from user;
注:MySQL 5.7版本password字段变成了authentication_string

7.设置任意ip可连接mysql

update user set host='%' where user='root';
flush privileges;#刷新权限表,使配置生效

8.设置只能本地连接mysql

update user set host='localhost' where user='root';
flush privileges;

9.添加一个用户名为net,密码为123456,任意ip都能连接的远程连接用户

grant all on *.* to 'net'@'%' identified by '123456';
flush privileges;

10.修改root密码

update user set password=password('123456') where user='root';
flush privileges;
注:MySQL 5.7版本password字段变成了authentication_string

11.设置mysql不区分表名大小写

vi /etc/my.cnf
在[mysqld]后添加  lower_case_table_names=1
重启MYSQL服务

发表评论