使用cmake安装单实例mysql
1、安装cmake
a、解压cmake包 b、编译 ./configure c、安装 make && make install
2、安装依赖包
yum install ncurses-devel -y
3、创建mysql用户
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
4、安装mysql
a、使用cmake编译
1 cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 2 -DMYSQL_DATADIR=/application/mysql-5.5.32/data 3 -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock 4 -DDEFAULT_CHARSET=utf8 5 -DDEFAULT_COLLATION=utf8_general_ci 6 -DEXTRA-CHARSETS=gbk,gb2312,utf8,ascii 7 -DENABLED_LOCAL_INFILE=ON 8 -DWITH_INNOBASE_STORAGE_ENGINE=1 9 -DWITH_FEDERATED_STORAGE_ENGINE=1 10 -DWITH_BLACHHOLE_STORAGE_ENGINE=1 11 -DWITH_MYISAM_STORAGE_ENGINE=1 12 -DWITH_EXAMPLE_STORAGE_ENGINE=1 13 -DWITH_MEMORY_STORAGE_ENGINE=1 14 -DWITH_PARTITION_STORAGE_ENGINE=1 15 -DWITH-FAST-MUTEXES=1 16 -DWITH-ZLIB=bundled 17 -DENABLED_LOCAL_INFILE=1 18 -DWITH_READLINE=1 19 -DWITH-EMBEDDED-SERVER=1 20 -DWITH-DEBUG=0
b、使用make安装
make && make install
c、创建连接
ln -s /application/mysql-5.5.32/ /application/mysql
5、配置mysql
cp /application/mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf
6、配置环境变量
1 echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile 2 tail -l /etc/profile 3 source /etc/profile 4 echo $PATH
7、初始化数据文件
1 mkdir –p /application/mysql/data 2 chown –R mysql.mysql /application/mysql 3 chmod -R 1777 /tmp/ 4 ./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
8、启动文件
1 a、复制启动文件 2 /bin/cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld 3 b、修改权限 4 chown -R mysql.mysql /application/mysql/ 5 chmod +x /etc/init.d/mysqld 6 c、启动mysql 7 /etc/init.d/mysqld start
9、删除用户为空的数据
1 delete from mysql.user where user=''; 2 delete from mysql.user where host='::1';
10、增加密码
1 /application/mysql//bin/mysqladmin -u root password 'new-password' 2 /application/mysql//bin/mysqladmin -u root -h jiajunpserver password 'new-password' 3 4 /application/mysql/bin/mysqladmin -u root password 'root@123'
11 开机自启动
1 chkconfig mysqld on 2 chkconfig --list mysqld
12、丢失root密码找回
a、停止数据库 /etc/init.d/mysqld stop b、使用—skip-grant-tables启动数据库 mysqld_safe –skip-grant-tables –user=mysql & c、使用update修改密码 update mysql.user set password=password(“root”) where user=’root’; d、刷新数据库 flush privileges; e、关闭数据库 mysqladmin –uroot –proot shutdown f、启动数据库 /etc/init.d/mysqld start
13、创建新用户并授权
a、创建jiajunp用户并可以访问db1数据库 grant all on db1.* to ‘jiajunp’@’localhost’ identified by ‘mypasswd’ b、授权局域网内主机远程连接数据库 grant all on test.* to jiajunp@’192.168.100.0/254’ identified by ‘jiajunp’;