1、下载mysql tar 包
2、上传tar包到/usr/local/下
3、解压tar包 并重命名为mysql,并且在mysql 目录下新建data目录
4、chown -R mysql:mysql mysql chmod -R 777 mysql
5 、如果support-files下没有my-default.cnf文件,那就自己创建一个加上相关配置,然后copy到/etc/my.cnf下添加如下配置
[mysql]
default-character-set=utf8
[mysqld]
basedir = /opt/mysql
datadir = /opt/mysql/data
port = 3306
default-storage-engine=INNODB
character_set_server=utf8
6、将support-files下的mysql.server copy到etc/init.d/mysql 下添加如下配置
basedir=/opt/mysql
datadir=/opt/mysql/data
7、配置mysql 环境变量 vim /etc/profile ,source profile
export MYSQL=/usr/local/mysql
export PATH=$MYSQL/bin:$PATH
8、初始化mysql ,记住初始化密码
./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
9、启动mysql ./bin/mysqld_safe --user=mysql &
10、登陆mysql 修改初始化密码
1)、首先修改root密码:alter user 'root'@'localhost' identified by '123456';
2)、其次,修改root用户可远程访问 update mysql.user set Host='%' where User = 'root';
3)、授予root 用户所有的权限 grant all privileges on *.* to 'root'@'%' with grant option;
4)、flush privileges;
11、设置mysql 开机自启动
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
网友评论