1.下载安装包
wget http://cdn.MySQL.com/archives/mysql-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz2.解压安装包
tar zxvf http://cdn.mysql.com/archives/mysql-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz3.进入文件夹
mv mysql-5.6.26-linux-glibc2.5-x86_64 mysqlcd mysql4.创建用户组和用户
groupadd mysqluseradd -r -g mysql mysql5.修改权限
chown -R mysql:mysql ./6.安装数据库
scripts/mysql_install_db --basedir=/opt/mysql/mysql --datadir=/opt/mysql/mysql/data --user=mysql如果出现以下异常:FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db: Data::Dumper 请安装依赖:yum install -y perl-Module-Install.noarch7.添加MySQL为系统服务
cp support-files/mysql.server /etc/init.d/mysql8.修改MySQL服务路径配置
vi /etc/init.d/mysql 修改 basedir=mysql安装包路径、datadir=mysql数据存放目录(默认为mysql安装包路径/data)9.修改MySQL配置文件
vim my.cnf配置如下:basedir = mysql安装路径datadir = mysql安装路径/dataport = 3306server_id = 1socket = /tmp/mysql.socklog_error = mysql安装路径/mysql-error.log9.添加MySQL系统变量
vi /etc/PRofile 修改PATH=$PATH:MYSQL安装包路径/bin source /etc/profile // 查看是否配置成功echo $PATH10.启动MySQL
service mysql start11.命令行连接MySQL
mysql -u root -p12.用户授权
// 创建一个远程用户使他有某个数据库的所有权限GRANT ALL PRIVILEGES ON 数据库名.* TO 用户名@"%" IDENTIFIED BY '密码' WITH GRANT OPTION;新闻热点
疑难解答