安装
ubuntu安装数据库相对比较简单,执行以下命令
sudo apt install mysql-server
目前时间是2021.7.31,默认安装的是mysql8.0。
mysql安装好后会附带一个mysql_secure_installation。可以通过他完成一些基础的设置
text@text-virtual-machine:~/桌面$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT 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 component?
#VALIDATE PASSWORD COMPONENT 可用于测试密码并提高安全性。 它检查密码的强度并允许用户只设置那些密码足够安全。 您想设置 VALIDATE PASSWORD 组件吗?
Press y|Y for Yes, any other key for No: 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 fortesting, and to make the installation go a bit smoother.You should remove them before moving into a production environment.
##默认情况下,MySQL 安装有一个匿名用户,允许任何人无需登录即可登录 MySQL为他们创建的用户帐户。 这仅适用于测试,并使安装更顺畅。你应该在进入生产之前删除它们环境。
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from'localhost'. This ensures that someone cannot guess at the root password from the network.
#通常,应该只允许 root 连接'本地主机'。 这确保了有人无法猜测来自网络的root密码。
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
... 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.
#默认情况下,MySQL 带有一个名为“test”的数据库任何人都可以访问。 这也仅用于测试,并且应该在进入生产之前被移除环境。
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changesmade 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 -uroot -p 并通过刚才设置密码登录数据库。
设置远程登录
终端输入 sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
然后取消#bind-address = 127.0.0.1 的注释,并将127.0.0.1修改为指定地址或者0.0.0.0就可以进行远程登录了

Comments NOTHING