标签:inux using x86_64 this mysq server exe tin 启动
最近申请了一台云主机,准备在云主机安装数据库mysql用。将安装过程记录一下。
1.安装mysql之前需要确保系统中有libaio依赖,使用如下命令:
yum search libaio
yum install libaio
进入centos终端操作界面,使用wget命令下载mysql5.7 64位安装文件:
wget -c https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
2.安装需要的编译工具
yum install cmake make ncurses-devel ncurses gcc gcc-c++ -y
3.解压源码包
tar -zxvf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz -C /usr/local
cd /usr/local
ln -s mysql-5.7.18-linux-glibc2.5-x86_64 mysql
4.开始编译安装
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock
-DMYSQL_DATADIR=/data/mysql/
-DSYSCONFDIR=/etc
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
-DWITH_XTRADB_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DWITH_EXTRA_CHARSETS=1
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DWITH_BIG_TABLES=1
-DWITH_DEBUG=0`
make
make install
5.设置开机启动和配置文件
cd /usr/local/mysql/
cp support-files/my-large.cnf/ etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig –add mysqld
chkconfig –level 35 mysqld on
mkdir -p /data/mysql
useradd mysql
6.初始化
/etc/init.d/mysqld/usr/local/mysql/scripts/mysql_install_db –user=mysql –datadir=/data/mysql/ –basedir=/usr/local/mysql56/
ln -s /usr/local/mysql55/bin/* /usr/bin/
7.登陆并修改密码
使用默认的密码登陆
mysql -uroot -p(这是一个MySQL的以密码登录root用户的命令)
用该密码登录到服务端后,必须马上修改密码再执行一些数据库操作,不然会报如下错误:
mysql> select @@log_error;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql>
修改密码(注意,登录后的操作后面都最好要有;结尾)
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘root123‘;
标签:inux using x86_64 this mysq server exe tin 启动
原文地址:https://blog.51cto.com/7704223/2399605