安装
打开终端直接开始,编码配置方法在后面
#通过apt更新包索引
sudo apt update
#按照默认软件包安装
sudo apt install mysql-server
#运行安全脚本
sudo mysql_secure_installation
这里会提醒安全等级
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:
按照要求选择安全等级,本地自用,选择0(最低等级,将来需要设置长度不少于8个字符的密码)
在Ubuntu系统中MySQL 5.7及之后的版本,MySQL的root用户被默认设置成通过auth_socket插件进行认证,而不是通过密码。在很多情况下,这些配置可以使系统更加的安全和可靠,但如果允许外部程序(例如phpMyAdmin)访问时,这将是事情变得非常复杂。
为了能够以root用户通过密码的方式连接MySQL,需要将其认证方式从 auth_socket 方式变更为mysql_native_password。进行该设置,通过终端打开MySQL的提示符:
更换默认的认证方式 (auth_socket ===》 mysql_native_password)
#启动MySQL
sudo mysql
#查看每个用户的认证方式
SELECT user,authentication_string,plugin,host FROM mysql.user;
#输出结果:
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | | auth_socket | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *0514040CAF65C120C8905B09219C0BA8010B2373 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)
#更改root的认证方式,auth_socket ===》 mysql_native_password
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '{PASSWORD};
#让数据库系统重新加载授权表
FLUSH PRIVILEGES;
#重新查看授权方式
SELECT user,authentication_string,plugin,host FROM mysql.user;
#输出结果:
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+-------------------------------------------+-----------------------+-----------+
| user | authentication_string | plugin | host |
+------------------+-------------------------------------------+-----------------------+-----------+
| root | *84AAC12F54AB666ECFC2A83C676908C8BBC381B1 | mysql_native_password | localhost |
| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost |
| debian-sys-maint | *0514040CAF65C120C8905B09219C0BA8010B2373 | mysql_native_password | localhost |
+------------------+-------------------------------------------+-----------------------+-----------+
4 rows in set (0.00 sec)
安装可视化工具 MySQL workbench
sudo apt-get install mysql-workbench
配置
Ubuntu默认语言是英语,安装MySQL后,默认建表插入语句时出现错误1336,这是默认编码与插入字符不符造成的。
修改方法如下:
#mysql默认配置文件夹
ls /etc/mysql/
conf.d debian-start my.cnf.fallback mysql.conf.d
debian.cnf my.cnf mysql.cnf
#修改mysql.conf.d文件夹下的配置文件
vim /mysql.conf.d/mysql.conf.d
#在[mysqld]块下追加一行字符设置 character-set-server=utf8
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
character-set-server=utf8
#还需要设置客户端的配置
cd /etc/mysql/conf.d
#修改该路径下的mysql.cnf,依然在[mysqld]后追加,内容稍有不同
default-character-set=utf8
Ubuntu18.04安装MySQL与默认编码设置的更多相关文章
-
ubuntu18.04 安装mysql不出现设置 root 帐户的密码问题(装)
ubuntu18.04 安装mysql不出现设置 root 帐户的密码问题 https://blog.csdn.net/NeptuneClouds/article/details/80995 ...
-
Ubuntu18.04 安装MySQL(Linux)解决登陆权限问题及Navicat for mysql 中文乱码问题
一.MySQL(Linux)解决登陆权限问题 Ubuntu18.04 安装mysql或者mariadb之后,发现普通用户和远程都没有权限连接. ERROR 1045: Access denied fo ...
-
ubuntu18.04安装mysql以及重置密码创建新用户
1.安装mysqlsudo apt-get install mysql-serversudo apt-get install mysql-clientsudo apt-get install libm ...
-
Ubuntu18.04安装MySQL教程
Ubuntu18.04下安装MySQL 提示:以下操作均在root权限下进行. # 查看有没有安装MySQL: dpkg -l | grep mysql # 安装MySQL: apt install ...
-
ubuntu18.04安装mysql
ubuntu18.04中,默认情况下mysql默认包含在apt软件存储库中,要安装它只需要更新服务器上的包索引并安装默认包apt-get. 1.安装mysql sudo apt-get update ...
-
ubuntu18.04 安装mysql server
mysql 5.7支持的最高版本是Ubuntu17 ,即使安装成功后,也会出现各种妖蛾子,本人就被这种问题困扰了好一会.在Ubuntu 18.04下安装mysql,建议安装8.0以上版本! 1. 配置 ...
-
Ubuntu18.04安装mysql(AWS云)
1.执行如下三条命令 sudo apt-get install mysql-server sudo apt install mysql-client sudo apt install libmysql ...
-
linux系统ubuntu18.04安装mysql(5.7)
本文是参考mysql官网整理而成,顺便把一些遇到的问题记载下来. ①将MySQLAPT存储库添加到系统的软件存储库列表中 ---->下载APT存储库(下载链接) ---->安装APT存 ...
-
阿里云服务器ECS Ubuntu18.04 安装mysql
ubuntu系统好了,这下我应该安装MySQL数据库了.在安装过程中,遇到好多坑,下面是我的安装过程. 1.在阿里云控制台,用vnc登录到服务器. 用新的用户登录到Ubuntu用户系统. 打开终端: ...
随机推荐
-
LeetCode-3LongestSubstringWithoutRepeatingCharacters(C#)
# 题目 3. Longest Substring Without Repeating Characters Given a string, find the length of the longes ...
-
javax.naming.NameNotFoundException:Name[ XXX] is not bound in this context.
在用局部数据源去连数据库的时候,在本地的项目中,都是可以的,可是一部署到服务器上,就报错了. 报的错误是:javax.naming.NameNotFoundException:Name[ XXX] i ...
-
Javascript基本算法演练 Seek and Destroy
转载自:http://aeroj-blog.logdown.com/posts/435808 Seek and Destroy You will be provided with an initial ...
-
IIS日志分析工具
发现一个强大的图形化IIS日志分析工具:Log Parser Studio. 安装 需要先安装Log Parser下载地址:http://www.microsoft.com/en-us/downloa ...
-
国内代码托管git-osc基础使用教程
git-osc是开源中国社区团队推出的基于Git的快速的.免费的.稳定的在线代码托管平台,不限制私有库和公有库数量.国内同类的有taocode.SVNchina等等 个人更喜欢git-osc的界面与操 ...
-
jmeter 正则表达式提取器的使用(提取第一个匹配结果)
原文地址https://www.cnblogs.com/xueli/p/7405258.html?utm_source=itdadao&utm_medium=referral 正则表达式的用处 ...
-
web页面超时自动退出方法
思路: 使用 mousemover 事件来监测是否有用户操作页面,写一个定时器间隔特定时间检测是否长时间未操作页面,如果是,退出: 具体时间代码如下(js):var lastTime = new Da ...
-
Android中的渐变
LinearGradient的用法 LinearGradient linearGradient; linearGradient = new LinearGradient(0, 0, 0, getHei ...
-
System.out.println与System.err.println的区别
public class Test2 { static { System.out.println("1"); } { System.out.println("2" ...
-
kali2.0下JAVA安装
参考网址:http://www.blackmoreops.com/2013/10/26/how-to-install-java-jdk-in-kali-linux/ 1.下载javase,http:/ ...