Ubuntu 安装MySQL

6 篇文章 0 订阅

1、下载mysql-apt-config资源包(资源包地址:https://dev.mysql.com/downloads/repo/apt/

2、将资源包放入apt库

sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb

3、更新apt库

sudo apt-get update

4、安装mysql服务(此过程中存在配置密码等,自行配置)

sudo apt-get install mysql-server

5、配置初始化信息

sudo mysql_secure_installation

root后输入密码

weison@ubuntu19-04:~$ 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: N(选择N,不会进行密码的强校验)
Please set the password for root here.

New password: 

Re-enter new password: 
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. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : N(选择N,不删除匿名用户)

 ... skipping.


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(选择N,允许root远程连接)

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N(选择N,不删除test数据库)

 ... skipping.
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(选择Y,修改权限立即生效)
Success.

All done! 

6、配置远程访问

# 登陆mysql
sudo mysql -uroot -p
#切换数据库
use mysql;
#查询用户表命令:
select User,authentication_string,Host from user;

访问权限说明:host默认都是localhost访问权限

host值访问权限
localhost本地连接
%本地+远程连接

7、创建一个用于远程登陆的账户

create user 'ubuntu'@'%' identified by '你的密码';
(ubuntu为用户名)

8、任何机器都能访问

grant all privileges on *.* to 'ubuntu'@'%' with grant option;

9、授权用户远程访问权限

GRANT ALL ON *.* TO 'ubuntu'@'%';

10、成功,链接地址为你的服务器的ip

Ubuntu安装MySQL有以下步骤: 1. 首先,卸载掉原来的MySQL。可以执行以下命令来清理残留数据并验证原有主机上是否安装MySQL: - sudo apt-get autoremove --purge mysql-server - sudo apt-get remove mysql-server - sudo apt-get autoremove mysql-server - sudo apt-get remove mysql-common - dpkg -l | grep ^rc | awk '{print $2}' | sudo xargs dpkg -P 2. 更新软件并安装MySQL: - sudo apt-get install update - sudo apt-get install upgrade - sudo apt-get install mysql-server - sudo apt-get install mysql-client - sudo apt-get install libmysqlclient-dev [2] 3. 安装完成后,可以通过以下命令来查看安装情况: - sudo netstat -tap | grep mysql 这样就可以在Ubuntu上成功安装MySQL了。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [ubuntu篇---ubuntu安装mysql教程](https://blog.csdn.net/m0_46825740/article/details/128145298)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Ubuntu如何安装Mysql](https://blog.csdn.net/weixin_44430893/article/details/119296615)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值