ubuntu16.04 能启动mysql服务

ubuntu16.04 后, 貌似mysqld/etc/init.d下,直接执行会报mysqld不在服务中,因此开启mysql服务失败。

所以执行以下命令不能启动mysql服务:
/etc/init.d/mysqld start

第一个念头就是把mysql加入系统服务中呗。

但是,一段捣鼓之后发现。。。

ubuntu16.04后, systemctl 代替了 chkconfig。。。

下面通过 systemctlmysqld加入服务,执行以下命令:

1.确认mysqld在/etc/init.d/目录下,

ls /etc/init.d/mysqld (mysqld只是 support-files/mysql.server 的一个拷贝别名文件而已)

2.查看mysqld是否在服务中

systemctl status mysqld
证明不在服务中

● mysqld.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
3.mysqld加入服务

systemctl start mysqld

4.再次查看mysqld是否在服务中

systemctl status mysqld

   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安装好, 那就顺便来个远程连接的设置吧。

1.选中mysql数据库:

mysql>use mysql;

2.查看用户和host:

mysql>select host,user,password from user;

+-----------+------+----------+
| host      | user | password |
+-----------+------+----------+
| localhost | root |          |
| ubuntu    | root |          |
| 127.0.0.1 | root |          |
| ::1       | root |          |
| localhost |      |          |
| ubuntu    |      |          |
+-----------+------+----------+
3.更新用户和host信息:

mysql> update user set host='%' where user='root';

Query OK, 0 rows affected (0.00 sec)
4.确认用户和host信息:

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)
5.退出:

mysql> quit

6.重启mysql:

shell>/etc/init.d/mysqld restart

7.远程连接mysql:

我用的是MySQL Workbench

转载于:https://www.cnblogs.com/liangjf/p/10634022.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值