当前位置:网站首页>Ubuntu系统安装与配置MySQL
Ubuntu系统安装与配置MySQL
2022-07-01 09:37:00 【伊木子曦】
一、安装MySQL
1. 安装mysql服务
sudo apt-get update
sudo apt install mysql-server-5.7
2. mysql版本
mysql -V
3. 查看MySQL默认账号和密码
sudo cat /etc/mysql/debian.cnf
二、配置MySQL
sudo mysql_secure_installation
#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N
#2
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入)
#3
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N
#4
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N
#5
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N
#6
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
三、查看mysql服务状态
systemctl status mysql.service
ps -ef|grep mysqld
四、修改root账户秘密认证方式
sudo cat /etc/mysql/debian.cnf
password后面的就是密码
然后在命令行输入:
mysql -u debian-sys-maint -p
- 在出现的Enter password输入上面的密码 ,进入mysql命令模式
- 创建数据库,修改密码
use mysql;
update mysql.user set authentication_string=('password') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;
quit;
五、配置远程访问mysql
1.修改配置文件,注释掉bind-address = 127.0.0.1
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
2. 保存退出,进入mysql
mysql -uroot -p
mysql> use mysql;
mysql> update user set host='%' where user = 'root';
mysql> flush privileges;
重启
sudo service mysql restart
查看状态
systemctl status mysql.service
六、删除MySQL
删除 mysql:
sudo apt autoremove --purge mysql-server-*
sudo apt remove mysql-server
sudo apt autoremove mysql-server
sudo apt remove mysql-common
清理残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
边栏推荐
- Simple load balancing with Nacos
- SQL学习笔记(02)——数据库表操作
- Huawei accounts work together at multiple ends to create a better internet life
- Exception handling of classes in C #
- SDN_简单总结
- 一个悄然崛起的国产软件,低调又强大!
- 项目采购管理
- js 使用toString 区分Object、Array
- SQL learning notes (01) - basic knowledge of database
- ES6 decoupling top-level objects from windows
猜你喜欢
How to launch circle of friends marketing and wechat group activities
PR training notes
我喜欢两个男人。。。
2.2 【pytorch】torchvision.transforms
2.2 【pytorch】torchvision. transforms
Design and manufacture of simple digital display electronic scale
nacos简易实现负载均衡
Cortex M4 systick details
Swift control encapsulation - paging controller
奇怪,为什么ArrayList初始化容量大小为10?
随机推荐
嵌入式开发用到的一些工具
JS rewrite their own functions
Matrix and coordinates
SQL learning notes (01) - basic knowledge of database
ESP8266 FreeRTOS开发环境搭建
3D printing Arduino four axis aircraft
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DHT11 +nodejs local service + MySQL database
dsPIC30F6014a LCD 方块显示
[unity rendering] customized screen post-processing
树结构---二叉树2非递归遍历
SQL学习笔记(02)——数据库表操作
js this丢失问题分析 及 解决方案
IPv6 learning notes
架构实战营 模块九:设计电商秒杀系统
Nacos service configuration and persistence configuration
phpexcel 里 获取某一列的列表 获取某一列的字母
Swag init error: cannot find type definition: response Response
项目采购管理
[pytorch] 2.4 convolution function nn conv2d
【leetcode】287. Find duplicates