uname -a
首先查看系统是32位还是64位操作系统,然后下载相应的mysql版本
创建mysql用户:
[root@localhost mysql]# useradd mysql
设置权限:
- [root@localhost mysql]# cd /usr/local
- [root@localhost local]# chown -R mysql:mysql mysql/
切换到mysql用户
- [root@localhost local]# su - mysql
- [mysql@localhost ~]$ cd /usr/local/mysql/scripts/
安装:
yum –y install perl perl-devel
[mysql@localhost scripts]$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
配置文件
-
cd /usr/local/mysql/support-files
-
cp my-default.cnf /etc/my.cnfcp mysql.server /etc/init.d/mysqlvim /etc/init.d/mysql #若mysql的安装目录是/usr/local/mysql,则可省略此步修改文件中的两个变更值basedir=/usr/local/mysql
datadir=/usr/local/mysql/data -
配置环境变量vi /etc/profile
-
export MYSQL_HOME=/usr/local/mysql
- export PATH=$MYSQL_HOME/bin:$PATH
保存退出source /etc/profile
-
启动
- [root@localhost mysql]# chkconfig --add mysql
- [root@localhost mysql]# chkconfig mysql on
- [root@localhost mysql]# service mysql start
- Starting MySQL.. SUCCESS!
登录:- /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
- [mysql@localhost ~]$ mysql -uroot -p
- Enter password:
- 设置登录权限:
- mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
- Query OK, 0 rows affected (0.06 sec)
- mysql> FLUSH PRIVILEGES;
- Query OK, 0 rows affected (0.04 sec)