赞
踩
到此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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。