ubuntu mysql 安装

来源:互联网 发布:mac如何彻底删除文件 编辑:程序博客网 时间:2024/05/21 00:19

安装

lychie@ubuntu:/setup$ sudo apt-get install mysql-server mysql-client
[sudo] password for lychie: ******
Reading package lists... Done
Building dependency tree
Reading state information... Done
. . . . . .  . . . . . .
After this operation, 93.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
. . . . . .  . . . . . .

 
一路 OK,就行了

更改密码

mysql -uroot -p登录 MySQL,安装的时候没有设置密码,提示输入密码的时候直接回车就完事

lychie@ubuntu:/setup$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 5.5.38-0ubuntu0.14.04.1 (Ubuntu)
 
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql>

update user set password=PASSWORD('******') where user='root';更改密码

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> select host, user, password from user;
+-----------+------------------+--------------+
| host      | user             | password     |
+-----------+------------------+--------------+
| localhost | root             |              |
| ubuntu    | root             |              |
| 127.0.0.1 | root             |              |
| ::1       | root             |              |
| localhost | debian-sys-maint | ******       |
+-----------+------------------+--------------+
5 rows in set (0.00 sec)
 
mysql> update user set password=PASSWORD('******') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0
 
mysql> select host, user, password from user;
+-----------+------------------+--------------+
| host      | user             | password     |
+-----------+------------------+--------------+
| localhost | root             | ******       |
| ubuntu    | root             | ******       |
| 127.0.0.1 | root             | ******       |
| ::1       | root             | ******       |
| localhost | debian-sys-maint | ******       |
+-----------+------------------+--------------+
5 rows in set (0.00 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

启动 / 停止 MySQL

sudo stop mysql     停止 MySQL
sudo start mysql    启动 MySQL

0 0
原创粉丝点击