mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz 安装

1、下载地址:MySQL-5.6.30-Linux-glibc2.5-x86_64.tar.gz

2、查看linux系统版本:

[mysql@localhost scripts]$ uname -a  
Linux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux  

3、解压缩下载的mysql包:

[root@localhost mysql]# tar -zxvf mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz -C /usr/local/

4、重命名解压包:

[root@localhost mysql]# mv mysql-5.6.30-linux-glibc2.5-x86_64 /usr/local/mysql

5、创建mysql用户:

[root@localhost mysql]# useradd mysql  

6、设置mysql用户密码:

[root@localhost mysql]# passwd mysql  

7、将mysql目录的权限授给mysql用户和mysql组:

[root@localhost local]# chown -R mysql:mysql /usr/local/mysql/ 

8、切换到mysql用户,执行安装:

[root@localhost ~]# su - mysql
[mysql@localhost scripts]$ /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

输出信息:

[mysql@localhost scripts]$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data  
Installing MySQL system tables...2016-04-17 07:41:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).  
2016-04-17 07:41:40 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.30) starting as process 3394 ...  
2016-04-17 07:41:40 3394 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)  

2016-04-17 07:41:40 3394 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)  

2016-04-17 07:41:40 3394 [Note] InnoDB: Using atomics to ref count buffer pool pages  
2016-04-17 07:41:40 3394 [Note] InnoDB: The InnoDB memory heap is disabled  
2016-04-17 07:41:40 3394 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins  
2016-04-17 07:41:40 3394 [Note] InnoDB: Memory barrier is not used  
2016-04-17 07:41:40 3394 [Note] InnoDB: Compressed tables use zlib 1.2.3  
2016-04-17 07:41:40 3394 [Note] InnoDB: Using Linux native AIO  
2016-04-17 07:41:40 3394 [Note] InnoDB: Using CPU crc32 instructions  
2016-04-17 07:41:40 3394 [Note] InnoDB: Initializing buffer pool, size = 128.0M  
2016-04-17 07:41:40 3394 [Note] InnoDB: Completed initialization of buffer pool  
2016-04-17 07:41:41 3394 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!  
2016-04-17 07:41:41 3394 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB  
2016-04-17 07:41:41 3394 [Note] InnoDB: Database physically writes the file full: wait...  
2016-04-17 07:41:41 3394 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB  
2016-04-17 07:41:42 3394 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB  
2016-04-17 07:41:44 3394 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0  
2016-04-17 07:41:44 3394 [Warning] InnoDB: New log files created, LSN=45781  
2016-04-17 07:41:44 3394 [Note] InnoDB: Doublewrite buffer not found: creating new  
2016-04-17 07:41:44 3394 [Note] InnoDB: Doublewrite buffer created  
2016-04-17 07:41:44 3394 [Note] InnoDB: 128 rollback segment(s) are active.  
2016-04-17 07:41:44 3394 [Warning] InnoDB: Creating foreign key constraint system tables.  
2016-04-17 07:41:44 3394 [Note] InnoDB: Foreign key constraint system tables created  
2016-04-17 07:41:44 3394 [Note] InnoDB: Creating tablespace and datafile system tables.  
2016-04-17 07:41:44 3394 [Note] InnoDB: Tablespace and datafile system tables created.  
2016-04-17 07:41:44 3394 [Note] InnoDB: Waiting for purge to start  
2016-04-17 07:41:44 3394 [Note] InnoDB: 5.6.30 started; log sequence number 0  
2016-04-17 07:41:45 3394 [Note] Binlog end  
2016-04-17 07:41:45 3394 [Note] InnoDB: FTS optimize thread exiting.  
2016-04-17 07:41:45 3394 [Note] InnoDB: Starting shutdown...  
2016-04-17 07:41:46 3394 [Note] InnoDB: Shutdown completed; log sequence number 1625977  
OK  

Filling help tables...2016-04-17 07:41:46 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).  
2016-04-17 07:41:46 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.30) starting as process 3417 ...  
2016-04-17 07:41:46 3417 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)  

2016-04-17 07:41:46 3417 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)  

2016-04-17 07:41:46 3417 [Note] InnoDB: Using atomics to ref count buffer pool pages  
2016-04-17 07:41:46 3417 [Note] InnoDB: The InnoDB memory heap is disabled  
2016-04-17 07:41:46 3417 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins  
2016-04-17 07:41:46 3417 [Note] InnoDB: Memory barrier is not used  
2016-04-17 07:41:46 3417 [Note] InnoDB: Compressed tables use zlib 1.2.3  
2016-04-17 07:41:46 3417 [Note] InnoDB: Using Linux native AIO  
2016-04-17 07:41:46 3417 [Note] InnoDB: Using CPU crc32 instructions  
2016-04-17 07:41:46 3417 [Note] InnoDB: Initializing buffer pool, size = 128.0M  
2016-04-17 07:41:46 3417 [Note] InnoDB: Completed initialization of buffer pool  
2016-04-17 07:41:46 3417 [Note] InnoDB: Highest supported file format is Barracuda.  
2016-04-17 07:41:46 3417 [Note] InnoDB: 128 rollback segment(s) are active.  
2016-04-17 07:41:46 3417 [Note] InnoDB: Waiting for purge to start  
2016-04-17 07:41:46 3417 [Note] InnoDB: 5.6.30 started; log sequence number 1625977  
2016-04-17 07:41:46 3417 [Note] Binlog end  
2016-04-17 07:41:46 3417 [Note] InnoDB: FTS optimize thread exiting.  
2016-04-17 07:41:46 3417 [Note] InnoDB: Starting shutdown...  
2016-04-17 07:41:48 3417 [Note] InnoDB: Shutdown completed; log sequence number 1625987  
OK  

To start mysqld at boot time you have to copy  
support-files/mysql.server to the right place for your system  

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !  
To do so, start the server, then issue the following commands:  

  /usr/local/mysql/bin/mysqladmin -u root password 'new-password'  
  /usr/local/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'  

Alternatively you can run:  

  /usr/local/mysql/bin/mysql_secure_installation  

which will also give you the option of removing the test  
databases and anonymous user created by default.  This is  
strongly recommended for production servers.  

See the manual for more instructions.  

You can start the MySQL daemon with:  

  cd . ; /usr/local/mysql/bin/mysqld_safe &  

You can test the MySQL daemon with mysql-test-run.pl  

  cd mysql-test ; perl mysql-test-run.pl  

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/local/mysql/my.cnf and  
will be used by default by the server when you start it.  
You may edit this file to change server settings  

WARNING: Default config file /etc/my.cnf exists on the system  
This file will be read by default by the MySQL server  
If you do not want to use this, either remove it, or use the  
--defaults-file argument to mysqld_safe when starting the server  

注意,如果安装报错:scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory,切换到root用户,安装perl以及perl-devel,执行命令:

[root@master ~]# yum -y install perl perl-devel

9、切换到root用户,复制并修改配置文件,添加msql服务:

复制文件:

[root@master ~]# cd /usr/local/mysql/support-files/
[root@master support-files]# cp my-default.cnf /etc/my.cnf
[root@master support-files]# cp mysql.server /etc/init.d/mysql

修改文件中的两个变更值

basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/

10、配置mysql的环境变量:

[root@master ~]# vi /etc/profile

添加如下内容:

export PATH=$PATH:/usr/local/mysql/bin

保存退出,执行:

[root@master ~]# source /etc/profile

11、切换到mysql用户,启用mysql:

[mysql@localhost ~]$ chkconfig --add mysql  
[mysql@localhost ~]$ chkconfig mysql on  
[mysql@localhost ~]$ service mysql start  
Starting MySQL.. SUCCESS!  

12、设置mysql的root用户密码:

[mysql@localhost ~]$ /usr/local/mysql/bin/mysqladmin -u root password '123456'

13、root用户登录mysql:

[mysql@localhost ~]$ mysql -uroot -p  
Enter password:   
Welcome to the MySQL monitor.  Commands end with ; or \g.  
Your MySQL connection id is 6  
Server version: 5.6.30 MySQL Community Server (GPL)  

Copyright (c) 2000, 2016, 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>  

注意:当执行quit退出再重新登录,可能报ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)异常,解决方法如下:

方法一:
(1)关闭mysql

[mysql@localhost ~]$  service mysql stop

(2)屏蔽权限

[mysql@localhost ~]$  mysqld_safe --skip-grant-table

屏幕出现: Starting demo from …..

(3)新开起一个终端输入

[mysql@localhost ~]$   mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql>quit

方法二:
(1)关闭mysql

[mysql@localhost ~]$  service mysql stop

(2)屏蔽权限

[mysql@localhost ~]$  mysqld_safe --skip-grant-table

屏幕出现: Starting demo from …..

(3)新开起一个终端输入

[mysql@localhost ~]$   mysql -u root mysql
mysql> delete from user where USER='';
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql>quit

14、分享:Linux终端操作MySQL常用命令

转载于:mysql-5.6.30-linux-glibc2.5-x86_64.tar.gz 安装

15、让远程客户端可以连接mysql服务器:

使用 mysql库 :

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` FROM user;

更新用户表 :

mysql> UPDATE user SET `Host` = '%' WHERE `User` = 'root' LIMIT 1;

注:host=localhost 那此用户就不具有远程访问权限,修改为%的意思是允许所有的ip远程访问,如果需要指定具体的某个ip就写上具体的ip即可

强制刷新权限 :

mysql> flush privileges;

或者通过授权的方式:

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

如果需要指定具体的某个ip就把%替换成具体的ip:

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

别忘记强制刷新权限 :

mysql> flush privileges;

补充,查看端口sql:

mysql>  show global variables like 'port';  

注:如果还不通,请查看防火墙信息。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值