PHP笔记网

革命尚未成功,同志仍须努力下载JDK17

作者:Albert.Wen  添加时间:2016-01-07 14:28:48  修改时间:2024-12-12 04:33:21  分类:Linux软件安装/参数优化  编辑

参考先前的文章:Ubuntu 14 编译安装 PHP 5.4.45 + 1.4.7 + MySQL 5.6.26 笔记

 

安装过程:

#安装依赖库
sudo apt-get install libaio-dev

#移动到安装目录
sudo mkdir /opt/software/mysql
cd /opt/software-backup/lnmp/source2/mysql
tar -xzvf ./mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
sudo mv ./mysql-5.6.26-linux-glibc2.5-x86_64/* /opt/software/mysql

# 新建用户
sudo groupadd mysql
sudo useradd -g mysql -s /usr/sbin/nologin mysql   #不让mysql用户直接登录
sudo chown -R mysql:mysql  /opt/software/mysql/

#初始化数据库
sudo /opt/software/mysql/scripts/mysql_install_db --basedir=/opt/software/mysql --datadir=/opt/software/mysql/data --user=mysql

#配置mysqld_safe(安装路径替换)
sudo sed -i "s#/usr/local/mysql#/opt/software/mysql#g" /opt/software/mysql/bin/mysqld_safe

#设置basedir, datadir
sudo sed -i "s#basedir=/usr/local/mysql#basedir=/opt/software/mysql#g" /etc/init.d/mysqld
sudo sed -i "s#datadir=/usr/local/mysql/data#datadir=/opt/software/mysql/data#g" /etc/init.d/mysqld
sudo sed -i "s#bindir=/usr/local/mysql/bin#bindir=/opt/software/mysql/bin#g" /etc/init.d/mysqld
sudo sed -i "s#libexecdir=/usr/local/mysql/bin#libexecdir=/opt/software/mysql/bin#g" /etc/init.d/mysqld

#修改配置文件
sudo cp /opt/software-backup/lnmp/config/my.cnf  /opt/software/mysql/

#设置开机自动启动
sudo cp /opt/software/mysql/support-files/mysql.server /etc/init.d/mysqld
sudo update-rc.d mysqld defaults
sudo service mysqld start #启动mysql
​
#设置root的密码为123456
sudo /opt/software/mysql/bin/mysqladmin -u root password

 

问题汇总:

后来,因为 Ubuntu 系统老被我弄得崩溃,为防止数据丢失,把 MySQL 的安装目录调整到 Windows 的“共享文件夹”中,即安装路径由 /opt/software/mysql 改为 /www/mysql

相关文章:【血的教训】玩 Ubuntu 遇到的致命问题(进不了系统)及 解决方案

重新整理上述安装脚本:

#安装依赖库
sudo apt-get install libaio-dev

#移动到安装目录
sudo mkdir /www/mysql
cd /opt/software-backup/lnmp/source2/mysql
tar -xzvf ./mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
sudo mv ./mysql-5.6.26-linux-glibc2.5-x86_64/* /www/mysql

# 新建用户
#sudo groupadd mysql
#sudo useradd -g mysql -s /usr/sbin/nologin mysql   #不让mysql用户直接登录
#sudo chown -R mysql:mysql  /www/mysql/
################################################
## 不新建用户了,使用当前 登录用户(jianbao)即可
################################################

#初始化数据库
sudo /www/mysql/scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=jianbao

#配置mysqld_safe(安装路径替换)
sudo sed -i "s#/usr/local/mysql#/www/mysql#g" /www/mysql/bin/mysqld_safe

#设置basedir, datadir
sudo sed -i "s#basedir=/usr/local/mysql#basedir=/www/mysql#g" /etc/init.d/mysqld
sudo sed -i "s#datadir=/usr/local/mysql/data#datadir=/www/mysql/data#g" /etc/init.d/mysqld
sudo sed -i "s#bindir=/usr/local/mysql/bin#bindir=/www/mysql/bin#g" /etc/init.d/mysqld
sudo sed -i "s#libexecdir=/usr/local/mysql/bin#libexecdir=/www/mysql/bin#g" /etc/init.d/mysqld

#修改配置文件
#sudo cp /opt/software-backup/lnmp/config/my.cnf  /www/mysql/my.cnf.bak
sudo cp /opt/software-backup/lnmp/config/my.cnf  /etc/

#设置开机自动启动
sudo cp /opt/software/mysql/support-files/mysql.server /etc/init.d/mysqld
sudo update-rc.d mysqld defaults
sudo service mysqld start #启动mysql
​
#设置root的密码为123456
sudo /www/mysql/bin/mysqladmin -u root password