ubuntu16.04
後, 貌似mysqld
在/etc/init.d
下,直接執行會報mysqld
不在服務中,所以開啓mysql
服務失敗。mysql
因此執行如下命令不能啓動mysql服務:
/etc/init.d/mysqld start
sql
第一個念頭就是把mysql
加入系統服務中唄。shell
可是,一段搗鼓以後發現。。。數據庫
ubuntu16.04
後, systemctl
代替了 chkconfig
。。。ubuntu
systemctl
把mysqld
加入服務,執行如下命令:ls /etc/init.d/mysqld (mysqld只是 support-files/mysql.server 的一個拷貝別名文件而已)
ui
systemctl status mysqld
證實不在服務中rest
● mysqld.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead)
systemctl start mysqld
code
systemctl status mysqld
server
mysqld.service - LSB: start and stop MySQL Loaded: loaded (/etc/init.d/mysqld; bad; vendor preset: enabled) Active: active (running) since Tue 2019-03-19 09:32:40 PDT; 6s ago Docs: man:systemd-sysv-generator(8) Process: 11364 ExecStart=/etc/init.d/mysqld start (code=exited, status=0/SUCCESS) CGroup: /system.slice/mysqld.service ├─11392 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/ubuntu.pid └─12330 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-erro
mysql安裝好, 那就順便來個遠程鏈接的設置吧。ci
mysql>use mysql;
mysql>select host,user,password from user;
+-----------+------+----------+ | host | user | password | +-----------+------+----------+ | localhost | root | | | ubuntu | root | | | 127.0.0.1 | root | | | ::1 | root | | | localhost | | | | ubuntu | | | +-----------+------+----------+
mysql> update user set host='%' where user='root';
Query OK, 0 rows affected (0.00 sec)
mysql> select user, host from user;
+------+-----------+ | user | host | +------+-----------+ | root | % | | root | 127.0.0.1 | | root | ::1 | | | localhost | | | ubuntu | | root | ubuntu | +------+-----------+ 6 rows in set (0.00 sec)
mysql> quit
shell>/etc/init.d/mysqld restart
我用的是MySQL Workbench