数据库应用(一): Ubuntu 下 MySQL 的 配置

  个人运气比较差,第一次装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

结果如图

配置界面如下:

#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (我的选项)

#2
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入)

#3
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...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (我的选项)

#4
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) : Y (我的选项)

#5
By default, 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 for No) : N (我的选项)

#6
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 (我的选项)

不同选项会有不同触发,认真看,英语不好翻译一下

  接着来检查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

  学习不易,诸君共勉!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值