Ubuntu 安装 mysql

来源:互联网 发布:iphone7 itunes mac 编辑:程序博客网 时间:2024/05/16 21:31

1.输入"sudo apt-get update"-->回车-->"输入mysql密码"

2.输入"sudo apt-get install mysql-server mysql-client"-->回车-->输入"y"-->回车-->在"软件包设置对话框"中输入mysql中"root"用户的密码-->回车-->再输一次密码-->回车,安装完成。

3.输入"sudo service mysql restart"-->回车-->显示下面2行说明安装成功

mysql stop/waiting
mysql start/running, process 6500

4.apache 支持mysql,输入"sudo apt-get install libapache2-mod-auth-mysql"-->回车

显示Setting up libapache2-mod-auth-mysql (4.3.9-13.1ubuntu3) ...说明安装成功

5.输入"mysql -u root -p"-->回车-->输入mysql中"root"用户的密码-->回车-->登录成功标示如下:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 36

---------------------远程连接mysql如下-------------------------

1./etc/mysql/my.cnf找到bind-address = 127.0.0.1

注释掉 或者改为: bind-address = 0.0.0.0

2.授权用户能进行远程连接

重启 MySQL:sudo /etc/init.d/mysql restart

grant all privileges on *.* to root@"%" identified by "password" with grant option;

flush privileges;

第一行命令解释如下,*.*:第一个*代表数据库名;第二个*代表表名。这里的意思是所有数据库里的所有表都授权给用户。root:授予root账号。“%”:表示授权的用户IP可以指定,这里代表任意的IP地址都能访问MySQL数据库。“password”:分配账号对应的密码,这里密码自己替换成你的mysql root帐号密码。

   第二行命令是刷新权限信息,也即是让我们所作的设置马上生效。


0 0
原创粉丝点击