Linux / ubantu 安装 MySql 数据库 Navicat远程访问

1.切换root权限: 输入 sudo su 回车,输入root帐号密码
2.安装MySql
说明:默认情况下,只有最新版本的MySql包含在APT软件包存储库中,安装最新版本的MySql只需更新服务器上的包索引,并安装默认的包 apt-get。

apt-get update
apt-get install mysql-server

安装过程中会弹出创建超级管理员的用户名和密码提示,选择你自己常用的且容易记住的用户名密码即刻
3.配置MySql
因为是全新安装,您需要运行附带的安全脚本。这会更改一些不太安全的默认选项,例如远程 root 登录和示例用户。在旧版本的 MySQL 上,您需要手动初始化数据目录,但 Mysql 5.7 已经自动完成了。
运行安全脚本。

sudo mysql_secure_installation

之后会有一下提示,选择自己合适的
root@localhost:/# sudo mysql_secure_installation (修改root密码)
Securing the MySQL server deployment.
Enter password for user root:
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(是否安装密码安全插件,开发环境可以选n)
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低,1中等,2强)
Invalid option provided.
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: 2
Using existing password for root.
Estimated strength of the password: 25
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
… skipping.
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(是否删除匿名用户)
… 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(是否禁止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(是否删除测试数据库)
… 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(是否重新加载权限)
Success.
All done!
到此MySql数据库安装完成!
4.检测MySql服务

查看进程:ps -ef|grep mysql
启动服务:service mysql start
停止服务:service mysql stop
重启服务:service mysql restart

5.设置MySQL远程访问权限

sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf (编辑此配置文件)
#bind-address = 127.0.0.1 (注释本地IP)
bind-address = 0.0.0.0 (或者 重新 添加一行)

退出编辑模式保存文件
进入MySql 命令行
mysql -u root -p 回车,输入密码
授权root用户访问权限,并刷新权限,此处的root可用其它MySQL用户替换,pwd部分需替换为该用户对应的密码
grant all privileges on *.* to root@"%" identified by "pwd" with grant option;(分配权限)
flush privileges;(刷新权限)
exit;(退出)
重启MySql服务
service mysql restart
6.查询防火墙状态
sudo ufw status
关闭防火墙
sudo ufw disable
开启 防火墙
sudo ufw enable
7.卸载MySql数据库

sudo apt purge mysql-*
sudo rm -rf /etc/mysql/ /var/lib/mysql
sudo apt autoremove
sudo apt autoclean

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ubuntu安装设置MySQL数据库,你可以按照以下步骤操作: 1. **更新系统**: 首先,确保你的系统是最新的,运行以下命令: ``` sudo apt update sudo apt upgrade ``` 2. **安装MySQL Server**: 使用`apt`包管理器安装MySQL,输入以下命令: ``` sudo apt install mysql-server ``` 安装过程中可能会提示你设置root用户的密码。 3. **启动与启用服务**: 安装完成后,启动MySQL服务并使其开机自启: ``` sudo systemctl start mysql sudo systemctl enable mysql ``` 4. **配置MySQL**: 如果你想配置MySQL,例如修改配置文件或创建新用户,可以编辑`/etc/mysql/mysql.conf.d/mysqld.cnf`文件。但是,一般情况下初次安装后不需要手动修改。 5. **登录MySQL**: 使用`mysql`命令或`mysql-client`工具连接到MySQL服务器(默认为root用户,输入之前设置密码): ``` sudo mysql -u root -p ``` 6. **创建数据库和用户**: 进入MySQL环境后,你可以使用`CREATE DATABASE`和`CREATE USER`命令来创建新的数据库和用户,然后授权访问。例如: ```sql CREATE DATABASE my_database; CREATE USER 'my_user'@'localhost' IDENTIFIED BY 'mypassword'; GRANT ALL PRIVILEGES ON my_database.* TO 'my_user'@'localhost'; FLUSH PRIVILEGES; ``` 7. **退出MySQL**: 完成操作后,记得退出MySQL: ``` exit ``` 8. **安全设置**: 建议对root用户进行更严格的限制,并为日常操作创建专门的用户,以提高安全性。 如果你在安装或使用过程中遇到问题,可以随时提问,我会为你提供帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值