0%

Ubuntu18.04 安装mysql

一、安装方法

Ubuntu18.04下安装MySQL

二、常用命令

  1.启动:/etc/init.d/mysql start
sudo service mysql restart

  2.停止:/etc/init.d/mysql stop

  3.重启:/etc/init.d/mysql restart

三、报错

1、Can’t connect to MySQL server on ‘‘ (61)

第一次安装可能是3306 只监听了localhost ,修改配置文件/etc/mysql/mysql.conf.d/mysqld.cnf中的bind-address为0.0.0.0即可
image

2、权限不够

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(1)SSH登录root管理员账户

(2)登录MySql

mysql -u root -p
Enter password:
(3)执行授权命令

mysql> grant all privileges on *.* to root@'localhost' identified by '密码';
mysql> flush privileges;


mysql> grant all privileges on *.* to root@'%' identified by '密码';
mysql> flush privileges;
(4)退出再试

mysql> quit
Bye
(5)再次登录

四、 supervisor 配置(可不用配置 默认后台自启动)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[program:mysql_3306]
command=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
process_name=mysql_3306
numprocs=1
;user=martin
autostart=true
autorestart=true
startsecs=10
startretries=7
stopsignal=TERM
stopwaitsecs=60
redirect_stderr=false
stdout_logfile=/root/log/mysql/mysql.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/root/log/mysql/mysql_error.log
stderr_logfile_maxbytes=50MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
;directory=/home/martin/data/logagent
serverurl=AUTO
------------- 本文结束 感谢您的阅读-------------