Linux系统如何安装配置Mysql服务?

2025-11-16 11:08:02

1、以root身份登录linux系统

Linux系统如何安装配置Mysql服务?

2、安装mysql-server

apt-get install mysql-server

Linux系统如何安装配置Mysql服务?

3、查看是否安装成功并启动

netstat -tap | grep mysql

Linux系统如何安装配置Mysql服务?

4、mysql在安装完成后自动启动,root账号密码为系统root密码

mysqladmin --version     查看mysql版本

sudo service mysql status   查看mysql状态

sudo service mysql start     启动mysql服务

sudo service mysql stop      停止mysql

Linux系统如何安装配置Mysql服务?

5、使用root登录mysql:

shell>mysql -u root -p

Linux系统如何安装配置Mysql服务?

6、添加其他账号并授权:

mysql>create user 'admin'@'localhost' identified by 'pwd';

mysql>grant all privileges on *.* to 'admin'@'localhost' with grant option;

指定域名,指定权限,指定database

mysql>create user 'dever'@'%.xxx.com' identified by 'pwd';

mysql>grant select,delete,drop,insert,update,create on your_database.* to 'dever'@'%.xxx.com';

7、查看用户 select host,user from user;

Linux系统如何安装配置Mysql服务?

8、开启mysql远程访问:

修改mysql配置文件:

vi  /etc/mysql/mysql.conf.d/mysqld.cnf

把其中bind-address = 127.0.0.1注释掉:

Linux系统如何安装配置Mysql服务?

9、登陆mysql修改权限

mysql>grant all on *.* to root@'%' identified by 'pwd';

flush privileges;

service mysql restart

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢