关键词

centos7.2_x64安装mysql.tar.gz

1.解压 tar mysql-5.6.17-linux-glibc2.5-i686.tar.gz

2.把解压好的文件移动到/usr/local/mysql 下 cp -r mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql

3.添加系统mysql组和mysql用户:执行命令:groupadd mysql和useradd -r -g mysql mysql

4.安装数据库:

1).修改当前目录拥有者为mysql用户:执行命令 chown -R mysql:mysql ./

2).安装数据库:执行命令 ./scripts/mysql_install_db --user=mysql

可能出现的问题:

-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory
提示注释器错误,没有/usr/bin/perl文件或者档案,解决办法(安装perl跟perl-devel即可):执行  yum -y install perl perl-devel

Can't locate Data/Dumper.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/l
ib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ./scripts/mysql_install_db line 42. 

解决办法:yum -y install autoconf

3)修改当前目录拥有者为root用户:执行命令 chown -R root:root ./

4)修改当前data目录拥有者为mysql用户:执行命令 chown -R mysql:mysql data

到此数据库安装完毕

Starting MySQL...The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).

 rm -rf /etc/my.cnf

2 原因

 

没有初始化权限表

 

 

 

3 解决办法

 

#cd /usr/local/mysql(进入mysql安装目录)
#chown -R mysql.mysql .
#su - mysql
$cd server
$scripts/mysql_install_db

 

 

 

4 本人解决过程

 

[root@localhost ~]# cd
/usr/local/mysql

 

[root@localhost mysql]# chown -R
mysql.mysql .
[root@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd /usr/local/mysql
[mysql@localhost mysql]$
scripts/mysql_install_db
Installing MySQL
system tables...
OK
Filling help tables...
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:

 

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

 

Alternatively you can run:
./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 . ; ./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 with the ./bin/mysqlbug script!

 

[mysql@localhost mysql]$ /usr/local/mysql/bin/mysqld_safe --user=mysql
&
[1] 11767
[mysql@localhost mysql]$ 120502 07:01:17 mysqld_safe Logging to
'/usr/local/mysql/data/localhost.localdomain.err'.
120502 07:01:17 mysqld_safe Starting mysqld daemon with databases
from /usr/local/mysql/data
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql status
MySQL running
(11830)                                     
[  OK  ]
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql start
Starting
MySQL                                            
[  OK  ]

 

 

 从任何主机上使用root用户,密码:youpassword(你的root密码)连接到mysql服务器:

# mysql -u root -proot 
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'youpassword' WITH GRANT OPTION;

1045错误

update user set authentication_string=PASSWORD('xxx') where User='root';

操作完后切记执行以下命令刷新权限 

FLUSH PRIVILEGES;

 使用命令show global variables like 'port';查看端口号

mysql 5.7 安装方法

/*******************************************************************************
* 安装环境
* 操作系统:Red Hat Linux Enterprise AS 4.0
* 数据库:mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
*******************************************************************************/
1. 下载Mysql 5.7.12 保存到 /usr/local 目录下
这里提供3种方法下载 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz文件,建议使用方法3
方法1:去官方下载
http://www.mysql.com/downloads/
找到MySQL Community Edition社区版点击Community (GPL) Downloads »
再找到MySQL Community Server 点击 Download
再选择平台   Linux Gerneric
再下载mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

方法2:Linux 用命令行直接下载
shell> cd /usr/local
shell> wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz

方法3:CSDN下载,上面两种方法都很耗时,官方网站网速不稳定,有时网站都打不开,下载都耗了好几个小时
我下载下来后分成了两卷,上传到CSDN供大家免费下载,下载地址:
http://download.csdn.net/detail/tan3739/9496846
http://download.csdn.net/detail/tan3739/9496800
上面的两个资源都下载好之后再解压,
解压后文件的MD5码与官方一致
MD5码: bc4071bd1313e43c8466922365e4381d

2.安装MySQL 5.7.12
shell> cd /usr/local
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> tar xzvf mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
shell> cd mysql-5.7.12-linux-glibc2.5-x86_64
shell> cp support-files/my-default.cnf /etc/my.cnf

shell> cd /usr/local
shell> ln -s mysql-5.7.12-linux-glibc2.5-x86_64 mysql
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> mkdir /usr/local/mysql/data
shell> ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
# 这里会有3条警告说“建议不要使用mysql_install_db来安装数据库,你应该使用mysqld --initialize来安装数据库”,不用管它。
    2016-03-30 17:28:48 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
    2016-03-30 17:28:59 [WARNING] The bootstrap log isn't empty:
    2016-03-30 17:28:59 [WARNING] 2016-03-30T09:28:49.052795Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead

shell> chown -R root .
shell> chown -R mysql data
# 启动MySQL
shell> cd /usr/local/mysql
shell> bin/mysqld_safe --user=mysql &

# 上面的命令就不多解释了,大多数的教程里面都有,这里主要说一下更改密码,
# 更改密码:mysql 5.6以后版本,第一次启动时会在root目录下生产一个随机密码,文件名.mysql_secret。
shell> cat /root/.mysql_secret

shell> /usr/local/mysql/bin/mysql -uroot -p
# password即.mysql_secret里的密码
# 用随机密码登录后,必须要更改密码,否则不能进行任何操作,更改密码:
mysql> SET PASSWORD = PASSWORD('newpasswd');

# 关闭MySQL服务
shell> /usr/local/mysql/bin/mysqladmin -u root -p shutdown

# 编辑PATH搜索路径
shell> vi /etc/profile

# 在profile文件末尾增加两行
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH

# 使PATH搜索路径立即生效:
shell> source /etc/profile

# 开机自动启动:
shell> cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
shell> chkconfig --add mysql

# 手动启动:以root身份执行:
shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &

 

本文链接:http://task.lmcjl.com/news/18883.html

展开阅读全文