LinuxMint安装Mysql

概览:

安装mysql

1
sudo apt install mysql-server

现在的mysql,默认安装时不提供设置密码。

所以,这能以默认用户登录来添加用户·及修改密码。

1
sudo nano /etc/mysql/debian.cnf

内容像这样

1
2
3
4
5
6
7
8
9
10
11
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = JVSGL6hCuThRoMcX
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = JVSGL6hCuThRoMcX
socket = /var/run/mysqld/mysqld.sock

以上信息可以得出:

用户名:debian-sys-maint

密码:JVSGL6hCuThRoMcX

查看用户列表

1
select user,host from mysql.user;

输出

1
2
3
4
5
6
7
8
9
10
mysql> select user,host from mysql.user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| debian-sys-maint | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
4 rows in set (0.00 sec)

修改密码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select user,plugin from user;
+------------------+-----------------------+
| user | plugin |
+------------------+-----------------------+
| root | auth_socket |
| mysql.session | mysql_native_password |
| mysql.sys | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+
4 rows in set (0.00 sec)


mysql> update user set authentication_string=password("88888888"),plugin='mysql_native_password' where user='root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1

mysql> select user,plugin from user;
+------------------+-----------------------+
| user | plugin |
+------------------+-----------------------+
| root | mysql_native_password |
| mysql.session | mysql_native_password |
| mysql.sys | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+
4 rows in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mardan@Mardan666-WS:~$ mysql -u root -p88888888
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.27-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2019, 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>

安装phpMyAdmin

1
2
3
sudo apt install apache2
sudo apt install phpmyadmin
sudo apt install libapache2-mod-php # apache2 需要此模块

软连接

1
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
------ 文章已经结束,谢谢你的阅读 ------
------ article has ended,thank you for reading ------
Thanks support Me

---------------- The End ----------------