Ubuntu安装mysql

                                              Ubuntu安装mysql

一、环境

       阿里云服务器,Ubuntu 14.04.5 LTS

       mysql版本:5.5.62

二、原有mysql卸载

dpkg --remove mysql-server
dpkg --remove mysql-client
apt-get purge -f mysql-server mysql-common
rm /var/lib/mysql/ -R
rm /etc/mysql/ -R
apt-get autoremove mysql* --purge
apt-get remove apparmor

三、安装mysql

    通过apt-get方式安装

apt-get install mysql-server

    安装过程提示设置密码

    mysql-server安装完成并运行

apt-get install mysql-client

   查看mysql运行状态

service mysql status

 

四、连接mysql服务器

    mysql命令,常用选项介绍

      -p, --password[=name] 
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty.

      -u, --user=name     User for login if not current user.

      -h, --host=name     Connect to host.

   

mysql -uroot -p

    输入安装时配置密码

    

五、密码重置或修改

    密码若忘了,可以先跳过输入密码阶段,进入数据库重置密码,步骤如下:

    1、跳过输入密码,进入mysql;

/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -uroot

    2、查看/配置新密码

show databases;
use mysql

    查看用户、密码

mysql> select user,host,password from user

    

    配置新密码

    

mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='root' or host='localhost';
mysql> FLUSH PRIVILEGES;

   退出mysql,重新启动: /etc/init.d/mysqld restart

    修改完成。

  

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值