Linux Mysql 学习笔记

mysql下载

http://mysql.mirrors.pair.com/Downloads/

 

 

Mysql安装步骤:

1、查看是否安装mysql:

 rpm -qa|grep -i mysql

 

2、如果有,先移除原来版本的mysql:

 rpm -ev --nodeps mysql-libs-5.5.37-1.el6.remi.x86_64

 

3、移除原mysql后,将mysql在linux平台上的安装包上传到/usr/rmp

 

4、进入/usr/rmp目录,分别安装mysql server/mysql client/mysql devel

 

 

[root@iZ94lys8uuzZ rmp]# rpm -ivh MySQL-server-5.6.25-1.el6.x86_64.rpm

Preparing...                ########################################### [100%]

   1:MySQL-server           ########################################### [100%]

2015-07-10 14:31:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

                          -----------略-----------

                          ------------略--------

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in '/root/.mysql_secret'.(默认生成的密码文件目录,可用tail命令打开)

 

You must change that password on your first connect,

no other statement but 'SET PASSWORD' will be accepted.

See the manual for the semantics of the 'password expired' flag.

 

Also, the account for the anonymous user has been removed.

 

In addition, you can run:

 

  /usr/bin/mysql_secure_installation

 

which will also give you the option of removing the test database.

This is strongly recommended for production servers.

 

See the manual for more instructions.

 

Please report any problems at http://bugs.mysql.com/

 

The latest information about MySQL is available on the web at

 

  http://www.mysql.com

 

Support MySQL by buying support/licenses at http://shop.mysql.com

 

New default config file was created as /usr/my.cnf and

will be used by default by the server when you start it.

You may edit this file to change server settings

[root@iZ94lys8uuzZ rmp]# rpm -ivh MySQL-client-5.6.25-1.el6.x86_64.rpm

Preparing...                ########################################### [100%]

   1:MySQL-client           ########################################### [100%]

[root@iZ94lys8uuzZ rmp]# rpm -ivh MySQL-devel-5.6.25-1.el6.x86_64.rpm

Preparing...                ########################################### [100%]

   1:MySQL-devel            ########################################### [100%]

 

5、打开密码文件:

[root@iZ94lys8uuzZ rmp]# tail /root/.mysql_secret

# The random password set for the root user at Fri Jul 10 14:31:26 2015 (local time): JQNSFByt6vuDiADX

 

6、查看mysql安装是否成功

[root@iZ94lys8uuzZ rmp]# rpm -qa|grep -i mysql

MySQL-server-5.6.25-1.el6.x86_64

MySQL-devel-5.6.25-1.el6.x86_64

MySQL-client-5.6.25-1.el6.x86_64

 

7、启动mysql服务

[root@iZ94lys8uuzZ rmp]# service mysql start

Starting MySQL. SUCCESS!

 

8、root登陆并修改原密码

[root@iZ94lys8uuzZ rmp]# mysql -u root -p

Enter password:

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

Your MySQL connection id is 1

Server version: 5.6.25

 

Copyright (c) 2000, 2015, 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> use mysql

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> SET PASSWORD = PASSWORD('123456');

Query OK, 0 rows affected (0.00 sec)

 

查询mysql用户:

mysql> use mysql;

mysql> select host, user from user;

+--------------+------+

| host         | user |

+--------------+------+

| 127.0.0.1    | root |

| ::1          | root |

| iz94lys8uuzz | root |

| localhost    | root |

+--------------+------+

4 rows in set (0.00 sec)

 

9、远程登陆授权

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'219.134.109.129' IDENTIFIED BY '123456' WITH GRANT OPTION;

Query OK, 0 rows affected (0.00 sec)

 

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

 

10、退出

mysql> exit

Bye

 

授权访问数据库:

grant all privileges on pinxing.* to 'root'@'localhost' identified by '123456';

FLUSH PRIVILEGES;

 

 

备注:

 

[root@iZ94lys8uuzZ ~]# rpm -qa|grep -i mysql

mysql-libs-5.5.37-1.el6.remi.x86_64

mysql-5.5.37-1.el6.remi.x86_64

perl-DBD-MySQL-4.013-3.el6.x86_64

compat-mysql51-5.1.54-1.el6.remi.x86_64

mysql-server-5.5.37-1.el6.remi.x86_64

 

关闭mysql服务:

[root@iZ94lys8uuzZ ~]# /etc/rc.d/init.d/mysqld stop

Stopping mysqld:                                           [  OK  ]

[root@iZ94lys8uuzZ ~]# /etc/rc.d/init.d/mysqld start

Starting mysqld:                                           [  OK  ]

[root@iZ94lys8uuzZ ~]# /etc/rc.d/init.d/mysqld stop

Stopping mysqld:                                           [  OK  ]

[root@iZ94lys8uuzZ ~]#

 

 

[root@iZ94lys8uuzZ ~]# service mysqld start

Starting mysqld:                                           [  OK  ]

[root@iZ94lys8uuzZ ~]# service mysqld stop

Stopping mysqld:                                           [  OK  ]

[root@iZ94lys8uuzZ ~]#

 

Linux启动/停止/重启Mysql数据库的方法

 

 

1、查看mysql版本

方法一:status;

方法二:select version();

 

2、Mysql启动、停止、重启常用命令

a、启动方式

1、使用 service 启动:

[root@localhost /]# service mysqld start (5.0版本是mysqld)

[root@szxdb etc]# service mysql start (5.5.7版本是mysql)

 

2、使用 mysqld 脚本启动:

/etc/inint.d/mysqld start

 

3、使用 safe_mysqld 启动:

safe_mysqld&

 

b、停止

1、使用 service 启动:

service mysqld stop

 

2、使用 mysqld 脚本启动:

/etc/inint.d/mysqld stop

 

3、mysqladmin shutdown

 

c、重启

1、使用 service 启动:

service mysqld restart

service mysql restart (5.5.7版本命令)

 

2、使用 mysqld 脚本启动:

/etc/init.d/mysqld restart

 

JQNSFByt6vuDiADX

 

 

 SET PASSWORD = PASSWORD('123456');

 

 

GRANT ALL PRIVILEGES ON *.* TO 'root'@'219.134.109.129' IDENTIFIED BY '123456' WITH GRANT OPTION;

 

FLUSH PRIVILEGES;

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值