个人运气比较差,第一次装mysql为了和QT对接,结果发下QT 要求试 MySQL 32位 的 装上去之后发现有bug 然后卸掉之后发现一个东西一直卸不掉,导致无法重新安装Mysql,成天以sqlite度日
就是这玩意,打死没卸掉
现在 要上实训课, 所以开启我两年前装的Ubuntu(捂脸),来安装一下MySQL
进入正题
第一步:
很显然得更新一下系统的软件源 sudo apt-get update 界面我就不给了,更新完,接着 就是 安装 mysql 了
一样 使用 apt 获取软件包 sudo apt-get install mysql-server ,回车后界面如下
回车继续即可
第二步
配置 Mysql ,命令行如下
sudo mysql_secure_installation
结果如图
配置界面如下:
#1VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key forNo: N (我的选项)
#2Pleaseset the password forroot here...
New password: (输入密码)
Re-enter newpassword: (重复输入)
#3Bydefault, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account createdforthem...
Remove anonymous users? (Press y|Y for Yes, any other key forNo) : N (我的选项)
#4Normally, root should only be allowed to connectfrom
'localhost'. This ensures that someone cannot guess at
the root passwordfromthe network...
Disallow root login remotely? (Press y|Y for Yes, any other key forNo) : Y (我的选项)
#5Bydefault, 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 forNo) : N (我的选项)
#6Reloading 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.servicus mysql.service
虽然说mysql不配置文件只能进行本地访问,不过用于 学习使用也是足够了
进入方法和window一样
mysql -u root -p
要注意, Ubuntu下要在 root模式下 输入这行命令
如图:
最后记录一下 启动和重启 命令
启动mysql:
方式一:sudo/etc/init.d/mysql start
方式二:sudo service mysql start
停止mysql:
方式一:sudo/etc/init.d/mysql stop
方式二:sudo service mysql stop
重启mysql:
方式一:sudo/etc/init.d/mysql restart
方式二:sudo service mysql restart
学习不易,诸君共勉!