Deepin15.11安装MariaDB

卸载旧版本

$ sudo apt autoremove mariadb-* mysql-*

安装MariaDB

$ sudo apt install mariadb-server mariadb-client

修改配置文件

$ sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf

[mysqld] 下增加增加一行 skip-grant-tables ,允许无密码进入 mysql ,并重启服务。

$ sudo service mysql restart

修改root用户密码

$ mysql -u root -p

直接回车即可,接下来修改 mysql 下的 root 用户密码

MariaDB [(none)]> 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
MariaDB [mysql]> update mysql.user set authentication_string=password('123456') where user='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 2  Changed: 1  Warnings: 0

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

允许远程登录

  • 修改配置文件 /etc/mysql/mariadb.conf.d/50-server.cnf ,修改服务绑定的 ip 地址,修改完重启数据库。

  • 更新数据库

MariaDB [(none)]> use mysql;
MariaDB [(none)]> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
MariaDB [(none)]> flush privileges;

重启数据库

$ sudo service mysql restart

查看数据库使用字符集

MariaDB [(none)]> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

若出现 character_set_databasecharacter_set_serverlatin1字符集,可修改 /etc/mysql/mariadb.conf.d/50-server.cnf,在 [mysql] 下增加一行 character-set-server=utf8

你可能感兴趣的:(Deepin15.11安装MariaDB)