ubuntu18.04下安装mariaDB

在windows10中安装了ubuntu18.04,需要安装mariadb

更新源或者替换源

之后进行安装

apt-get install mariadb-server

启动和停止

sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql stop

在这里插入图片描述

设置密码

sudo mysql_secure_installation  

ubuntu18.04下安装mariaDB_第1张图片
上面可以配置登录密码,是否允许远程访问等。

后续的一些配置

5.使用navicate远程连接时出现"10061error“

解决方法:

(1) 修改/etc/mysql/my.cnf文件。打开文件,找到下面内容:

 # Instead of skip-networking the default is now to listen only on
 # localhost which is more compatible and is not less secure.
 bind-address  = 127.0.0.1
 # 把上面这一行注释掉或者把127.0.0.1换成合适的IP,建议注释掉。

(2)但现在最新版的mariaDB 已将配置文件拆分此时my.cnf文件里面显示如下

!includedir /etc/mysqql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
# 这两句话的意思是配置文件包含了上面两个文件夹所有的文件,那么现在一一查找bind-address  = 127.0.0.1这句话写在哪了。
之后在/etc/mysql/mariadb.conf.d/50-server.cnf此文件下找到bind-address = 127.0.0.1这句话,注释掉就行了。
ubuntu@DESKTOP-22ADTJ6:/etc/mysql/mariadb.conf.d$ ll
total 12
drwxr-xr-x 1 root root 4096 Apr  5 04:13 ./
drwxr-xr-x 1 root root 4096 Apr  5 13:06 ../
-rw-r--r-- 1 root root  733 Jan 30 15:25 50-client.cnf
-rw-r--r-- 1 root root  336 Jan 30 15:25 50-mysql-clients.cnf
-rw-r--r-- 1 root root 1032 Jan 30 15:25 50-mysqld_safe.cnf
-rw-r--r-- 1 root root 3719 Jan 30 15:25 50-server.cnf
ubuntu@DESKTOP-22ADTJ6:/etc/mysql/mariadb.conf.d$ pwd
/etc/mysql/mariadb.conf.d
ubuntu@DESKTOP-22ADTJ6:/etc/mysql/mariadb.conf.d$ 

编辑文件

ubuntu@DESKTOP-22ADTJ6:/etc/mysql/mariadb.conf.d$ sudo vi 50-server.cnf

#bind-address           = 127.0.0.1 				#注释这行

修改后重启即可

ubuntu@DESKTOP-22ADTJ6:/etc/mysql/mariadb.conf.d$ sudo /etc/init.d/mysql restart
 * Stopping MariaDB database server mysqld
   ...done.
 * Starting MariaDB database server mysqld
   ...done.
ubuntu@DESKTOP-22ADTJ6:/etc/mysql/mariadb.conf.d$ 

出现这样的提示,应该是mysql的主机设置了访问的主机,需要只需登录主机,只需如下命令即可

sudo mysql -uroot -p
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;

记录

ubuntu@DESKTOP-22ADTJ6:~$ sudo mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 34
Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> 

ubuntu18.04下安装mariaDB_第2张图片

出现 ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’ 可能是没有权限,加上sudo即可

ubuntu@DESKTOP-22ADTJ6:~$ mysql -uroot -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
ubuntu@DESKTOP-22ADTJ6:~$ sudo mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor

你可能感兴趣的:(linux,环境安装,mysql)