在Ubuntu 18.04上,默认情况下,只有最新版本的 MySQL 包含在APT软件包存储库中。目前来说是MySQL 5.7。
在安装之前需要更新服务器上的软件包索引然后才能使用apt安装默认软件包:
$ sudo apt update
$ sudo apt install mysql-server
$ sudo mysql_secure_installation
接下来将会通过一系列提示来对MySQL安装的安全选项进行一些更改(这一步非常重要):
首先便是要求设置root用户的密码:
$ 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
Please set the password for root here.
New password:
Re-enter new password:
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
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) : 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.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
… 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) : Y
Dropping test database…
Success.
Removing privileges on test database…
Success.
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的运行状态:
$ systemctl status mysql.service
显示结果如下即表示mysql正在运行
使用root命令和刚才设置的密码来登陆到 mysql中去
$ mysql -uroot -p
然后报了一处错误:
$ mysql -uroot -p
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
我是借鉴了此篇博客
我先查询表,然后对表进行删除,最后添加表
也可以在这个命令前面加 sudo 执行,不过我编了一个Python程序,执行的时候报了一个这个错误
借鉴了此篇博客问题得到了解决
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
最终完成了MyServer的安装,远程设置有需要的可以参考文章开始的那篇博客
mysql -u root -p
use mysql;
然后导入数据库文件
source path/file.sql #path为文件真实路径
pip install numpy==1.17.0