XUBUNTU下安装配置mysql或mariadb,以及workbench远程连接数据库服务
2017-04-03 21:36
971 查看
安装mysql或mariadb
由于xubuntu上装了mariadb,不论系统还是应用都略非主流
特此记录配置过程
不废话 选mariadb
sudo apt-get install mariadb-common mariadb-client mariadb-server
怕出错麻烦的可以
sudo apt-get install mariadb*
启动
sudo systemctl start mariadb
或
service mysql start
开始初始化配置
mysql_secure_installation
Enter current password for root (enter for none): 当前无密码 直接回车
New password: 为root用户设置数据库密码
Re-enter new password:确认密码
Remove anonymous users? [Y/n] y 删除匿名帐号
Disallow root login remotely? [Y/n] y 禁止root用户从远程登录
Remove test database and access to it? [Y/n] y 删除test数据库并取消对其的访问权限
Reload privilege tables now? [Y/n] y 刷新授权表,让初始化后的设定立即生效
登录数据库
mysql -u root -p
输入root登录密码
进入
MariaDB [(none)]>
开始创建用户
创建数据库用户的命令:CREATE USER 用户名@主机名 IDENTIFIED BY '密码';
MariaDB [(none)]> create user sky92@localhost IDENTIFIED BY 'xxx';
MariaDB [(none)]> exit
退出
登录刚才创建的用户
mysql -u sky92 -p
然后输入密码
远程连接前服务端的配置
停止mysql服务
sudo service mysql stop
编辑配置文件 (这个位置在debian系的mariadb中和RH的不同)
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
找到[mysqld]下
找到
bind-address = 127.0.0.1
skip-networking
注释掉改行
#bind-address = 127.0.0.1
#skip-networking
保存退出
然后使用root登录
mysql -u root -p
输入密码后 输入执行下部语句
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.%.%' IDENTIFIED BY 'my-new-password' WITH GRANT OPTION;
该语句允许所有用户远程以root在192.168.x.x网段中登录数据库
同样可以用对sky92用户一样操作
exit退出
客户端使用mysql-workbench远程连接
sudo usr/bin/mysql-workbench
输入服务端IP 默认端口3306
sky92或者root
然后连接
错误问题参考连接
1044
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'sky92'@localhost IDENTIFIED BY 'password' WITH GRANT OPTI
4000
ON;
http://www.linuxidc.com/Linux/2017-03/141240.htm
1698
http://blog.csdn.net/ryshiki/article/details/50459008
之前MySQL服务端本机上使用密码登陆root账号是没有问题的,但是今天不知道是因为动了哪里,登陆失败并有这个错误代码:
解决步骤:
停止mysql服务
以安全模式启动MySQL
MySQL启动之后就可以不用密码登陆了
查看一下user表,错误的起因就是在这里, root的plugin被修改成了auth_socket,用密码登陆的plugin应该是mysql_native_password。
关于auth_socket,在官方有说明: https://dev.mysql.com/doc/mysql-security-excerpt/5.5/en/socket-authentication-plugin.html ,反正现在暂时不用它,
那就把这里改了。
重启服务,问题就解决了
由于xubuntu上装了mariadb,不论系统还是应用都略非主流
特此记录配置过程
不废话 选mariadb
sudo apt-get install mariadb-common mariadb-client mariadb-server
怕出错麻烦的可以
sudo apt-get install mariadb*
启动
sudo systemctl start mariadb
或
service mysql start
开始初始化配置
mysql_secure_installation
Enter current password for root (enter for none): 当前无密码 直接回车
New password: 为root用户设置数据库密码
Re-enter new password:确认密码
Remove anonymous users? [Y/n] y 删除匿名帐号
Disallow root login remotely? [Y/n] y 禁止root用户从远程登录
Remove test database and access to it? [Y/n] y 删除test数据库并取消对其的访问权限
Reload privilege tables now? [Y/n] y 刷新授权表,让初始化后的设定立即生效
登录数据库
mysql -u root -p
输入root登录密码
进入
MariaDB [(none)]>
开始创建用户
创建数据库用户的命令:CREATE USER 用户名@主机名 IDENTIFIED BY '密码';
MariaDB [(none)]> create user sky92@localhost IDENTIFIED BY 'xxx';
MariaDB [(none)]> exit
退出
登录刚才创建的用户
mysql -u sky92 -p
然后输入密码
远程连接前服务端的配置
停止mysql服务
sudo service mysql stop
编辑配置文件 (这个位置在debian系的mariadb中和RH的不同)
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
找到[mysqld]下
找到
bind-address = 127.0.0.1
skip-networking
注释掉改行
#bind-address = 127.0.0.1
#skip-networking
保存退出
然后使用root登录
mysql -u root -p
输入密码后 输入执行下部语句
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.%.%' IDENTIFIED BY 'my-new-password' WITH GRANT OPTION;
该语句允许所有用户远程以root在192.168.x.x网段中登录数据库
同样可以用对sky92用户一样操作
exit退出
客户端使用mysql-workbench远程连接
sudo usr/bin/mysql-workbench
输入服务端IP 默认端口3306
sky92或者root
然后连接
错误问题参考连接
1044
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'sky92'@localhost IDENTIFIED BY 'password' WITH GRANT OPTI
4000
ON;
1045
http://www.linuxidc.com/Linux/2017-03/141240.htm
1698http://blog.csdn.net/ryshiki/article/details/50459008
之前MySQL服务端本机上使用密码登陆root账号是没有问题的,但是今天不知道是因为动了哪里,登陆失败并有这个错误代码:
~$ mysql -u root -p Enter password: ERROR 1698 (28000): Access denied for user 'root'@'localhost'
解决步骤:
停止mysql服务
~$ sudo service mysql stop
以安全模式启动MySQL
~$ sudo mysqld_safe --skip-grant-tables &
MySQL启动之后就可以不用密码登陆了
~$ mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.10 MySQL Community Server (GPL)
查看一下user表,错误的起因就是在这里, root的plugin被修改成了auth_socket,用密码登陆的plugin应该是mysql_native_password。
mysql> select user, plugin from mysql.user; +-----------+-----------------------+ | user | plugin | +-----------+-----------------------+ | root | auth_socket | | mysql.sys | mysql_native_password | | dev | mysql_native_password | +-----------+-----------------------+ 3 rows in set (0.01 sec)
关于auth_socket,在官方有说明: https://dev.mysql.com/doc/mysql-security-excerpt/5.5/en/socket-authentication-plugin.html ,反正现在暂时不用它,
那就把这里改了。
mysql> update mysql.user set authentication_string=PASSWORD('newPwd'), 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> flush privileges; Query OK, 0 rows affected (0.00 sec)
重启服务,问题就解决了
~$ sudo service mysql stop ... * MySQL Community Server 5.7.10 is stopped ~$ sudo service mysql start .. * MySQL Community Server 5.7.10 is started ~$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.10 MySQL Community Server (GPL)
相关文章推荐
- oracle基础(数据库名,实例名,操作系统环境变量Oracle_Sid,全局数据库名,服务名等概念)以及Oracle客户端的安装与远程连接配置
- CentOS7.0 MariaDB 安装配置后使用远程工具SQLyog 错误1130(远程连接mysql 授权)
- Ubuntu の MySQL 数据库服务配置和远程连接使用教程
- 【数据库】mysql压缩包的安装、配置、配成windows服务、远程连接及常规问题
- mysql/sqlserver/oracle安装以及设置远程连接数据库访问
- Ubuntu安装Mysql以及配置远程连接(笔记)
- Mysql 服务无法启动 服务没有报告任何错误(mysql5.7安装及修改密码,修改远程连接数据库)
- Ubuntu下MySQL的安装及远程连接配置等配置
- ubuntu下MySQL的安装及远程连接配置等配置
- python下使用mysql.connector 安装以及连接数据库的操作
- ubuntu下MySQL的安装及远程连接配置等配置
- [数据库]mysql 5.6.20的安装、配置服务、设置编码格式
- mysql的安装与简单使用以及myeclipse下与数据库的连接和使用
- linux - yum 安装配置mysql可以远程连接
- ubuntu下MySQL的安装及远程连接配置等配置
- pl/sql 如何配置连接远程一个或多个数据库(1.同一个ip不同用户名,2.不同ip不同用户名)以及记住密码
- mysql安装,配置,远程连接
- Mysql 新建用户 远程连接数据库 (mysql workbench/命令行)
- ubuntu下MySQL的安装及远程连接配置等配置
- Ubuntu下MySQL的安装及远程连接配置等配置