useradd -r -s /sbin/nologin -M mysql
mkdir -p /opt/data/var
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
/etc/init.d/iptables stop
chkconfig iptables off
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/data/mysql \
-DMYSQL_DATADIR=/opt/data/var \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
chown -R mysql:mysql /opt/data/
mv /etc/my.cnf /etc/my.cnf.bak
scripts/mysql_install_db --basedir=/opt/data/mysql/ --datadir=/opt/data/var/ --user=mysql #初始化
bin/mysqld_safe --user=mysql & #启动
cp support-files/mysql.server /etc/init.d/
chkconfig mysql.server on
service mysql start --启动MySQL
echo ‘PATH=/opt/data/mysql/bin:$PATH‘ >> /etc/profile
echo ‘export PATH‘ >> /etc/profile
source /etc/profile
mysqladmin -u root password "medlinker"
注:在启动MySQL服务时,会按照一定次序搜索my.cnf,先在/etc目录下找,找不到则会搜索"$basedir/my.cnf",在本例中就是 /usr/local/mysql/my.cnf,这是新版MySQL的配置文件的默认位置!
注意:在CentOS 6.4版操作系统的最小安装完成后,在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.bak,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。
在使用"yum update"更新系统后,需要检查下/etc目录下是否会多出一个my.cnf,如果多出,将它重命名成别的。否则,MySQL将使用这个配置文件启动,可能造成无法正常启动等问题。
server_id = 223
log-bin=mysql-bin
grant replication slave on *.* to ‘backup‘@‘192.168.1.224‘ identified by ‘medlinker‘;
show master status;
change master to master_host=‘192.168.1.223‘,master_user=‘backup‘,master_password=‘medlinker‘,master_log_file=‘mysql-bin.000002‘,master_log_pos=120;
start slave;
show slave status\G
授权开发使用:
grant all on *.* to ‘root‘@‘%‘ identified by ‘medlinker‘;
二进制安装mysql 5.6
tar xf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz
ln -sv mysql-5.6.29-linux-glibc2.5-x86_64 mysql
useradd -r -s /sbin/nologin -M mysql
chown mysql.mysql mysql-5.6.29-linux-glibc2.5-x86_64 -R
cd scripts/
./mysql_install_db --basedir=/opt/mysql --datadir=/opt/mysql/data/ --user=mysql
./bin/mysqld_safe --defaults-file=my.cnf &
netstat -tnulp
二进制安装mysql 5.7
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chmod 770 mysql-files
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> bin/mysql_install_db --user=mysql # Before MySQL 5.7.6
shell> bin/mysqld --initialize --user=mysql # MySQL 5.7.6 and up
shell> bin/mysql_ssl_rsa_setup # MySQL 5.7.6 and up
shell> chown -R root .
shell> chown -R mysql data mysql-files
shell> bin/mysqld_safe --user=mysql &
初始化数据库,注意密码
./bin/mysqld --initialize --basedir=/opt/mysql7/ --datadir=/opt/mysql7/data/ --user=mysql
./bin/mysqld_safe --user=mysql &
# ./bin/mysqladmin -u root -p password "wqh"
mysql> alter user ‘root‘@‘localhost‘ identified by ‘mysql‘;
mysql> flush privileges;
原文地址:http://wangqh.blog.51cto.com/5367393/1766113