当前位置:   article > 正文

ubuntu 16.04mysql安装_ubuntu 16.04.1 上MySQL的安装与配置

journal has been rotated since unit was started

到此MySQL服务器就安装成功了,下面我们验证一下是否安装成功,并做一些配置,免得产生不必要的麻烦:

查看进程:

root@VM-202-164-ubuntu:/home/ubuntu# ps -aux|grep mysql|grep -v grep

mysql 27866 0.0 29.7 1148940 263592 ? Ssl Nov14 19:38 /usr/sbin/mysqld

说明:查看是否存在MySQL进程

查看端口:

root@VM-202-164-ubuntu:/home/ubuntu# netstat -nlt|grep 3306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

说明:MySQL默认使用3306端口,查看该端口的状态

查看service状态:

root@VM-202-164-ubuntu:/home/ubuntu# service mysql status

● mysql.service - MySQL Community Server

Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)

Active: active (running) since Tue 2017-11-14 22:50:15 CST; 1 months 1 days ago

Main PID: 27866 (mysqld)

Tasks: 35

Memory: 263.1M

CPU: 19min 39.122s

CGroup: /system.slice/mysql.service

└─27866 /usr/sbin/mysqld

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

root@VM-202-164-ubuntu:/home/ubuntu#

说明:显示如上结果,说明service正常

通过启动命令检查MySQL服务器状态:

root@VM-202-164-ubuntu:/home/ubuntu# service mysql status

● mysql.service - MySQL Community Server

Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)

Active: active (running) since Tue 2017-11-14 22:50:15 CST; 1 months 1 days ago

Main PID: 27866 (mysqld)

Tasks: 35

Memory: 263.1M

CPU: 19min 39.122s

CGroup: /system.slice/mysql.service

└─27866 /usr/sbin/mysqld

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

root@VM-202-164-ubuntu:/home/ubuntu# /etc/init.d/mysql status

● mysql.service - MySQL Community Server

Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)

Active: active (running) since Tue 2017-11-14 22:50:15 CST; 1 months 1 days ago

Main PID: 27866 (mysqld)

Tasks: 35

Memory: 263.1M

CPU: 19min 39.177s

CGroup: /system.slice/mysql.service

└─27866 /usr/sbin/mysqld

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

root@VM-202-164-ubuntu:/home/ubuntu#

说明:显示如上结果,说明MySQL服务器状态正常。

到此MySQL数据库就可以正常使用了,可以试一下:

root@VM-202-164-ubuntu:/home/ubuntu# mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 30257

Server version: 5.7.20-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

执行mysql -u root -p ,输入刚刚设置的数据库root用户的密码(注意是数据库用户而不是系统用户哦),进入MySQL命令行界面,在Windows上用过MySQL的你对这个界面一定很熟悉了吧。写两个sql试试感觉:

mysql> use mysql;

Database changed

mysql> select * from user;

-- 一堆结果,不粘了,输入exit命令退出MySQL命令行

mysql>exit

Bye

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/115230
推荐阅读
相关标签
  

闽ICP备14008679号