二进制安装: [[email protected] ~]# mkdir /home/lufeng/tools -p [[email protected] ~]# cd /home/lufeng/tools [[email protected] tools]# rz [[email protected] tools]# tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz [[email protected] tools]# mkdir -p /application/mysql-5.5.49 [[email protected] tools]# mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49 创建mysql用户|组 [[email protected] tools]# groupadd mysql [[email protected] tools]# useradd mysql -g mysql -s /sbin/nologin -M 初始化配置文件 [[email protected] tools]# ln -s /application/mysql-5.5.49/ /application/mysql [[email protected] tools]# cd /application/mysql [[email protected] mysql]# cp support-files/my-small.cnf /etc/my.cnf 初始化数据库文件 [[email protected] mysql]# mkdir -p /application/mysql/data [[email protected] mysql]# chown -R mysql.mysql /application/mysql/ [[email protected] mysql]# /application/mysql/scripts/mysql_install_db --basedir=/application//mysql --datadir=/application/mysql/data --user=mysql 配置并启动mysql [[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld [[email protected] mysql]# chmod +x /etc/init.d/mysqld [email protected] mysql]# sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe /etc/init.d/mysqld [[email protected] mysql]# /etc/init.d/mysqld start Starting MySQL... SUCCESS! [[email protected] mysql]# netstat -lntup|grep mysql tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2951/mysqld 配置全局使用路径 [[email protected] ~]# echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile [[email protected] ~]# tail -1 /etc/profile export PATH=/application/mysql/bin:$PATH [[email protected] ~]# echo $PATH /application/mysql/bin:/applicaion/mysql/bin:/applicaion/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin 安全配置: [[email protected] ~]# mysqladmin -u root password ‘199429‘ [[email protected] ~]# mysql ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO) [[email protected] ~]# mysql -uroot -p 删除多余用户: +------+-----------+ | user | host | +------+-----------+ | root | 127.0.0.1 | | root | localhost | +------+-----------+
时间: 2024-10-22 22:45:55