Linux system installation mysql database

1. First download  Mysql5.6 from the official website

download link:
http://downloads.mysql.com/archives/get/file/mysql-5.6.27-linux-glibc2.5-x86_64.tar.gz

2. Use the following commands to view the current installation of mysql and find out whether mysql was previously installed

rpm -qa|grep -i mysql

It can be seen as shown in the following figure:

Shows that it was installed before:

     MySQL-client-5.5.25a-1.rhel5

     MySQL-server-5.5.25a-1.rhel5

3. Stop the mysql service and delete the previously installed mysql

delete command:rpm -e –nodeps 包名

rpm -ev MySQL-client-5.5.25a-1.rhel5
rpm -ev MySQL-server-5.5.25a-1.rhel5

Special Note: If you are not the root user, remember to add sudo in front of the command

If it prompts a dependency package error, use the following command to try

rpm -ev MySQL-client-5.5.25a-1.rhel5 --nodeps

If it prompts an error:error: %preun(xxxxxx) scriptlet failed, exit status 1

Then try with the following command:

rpm -e --noscripts MySQL-client-5.5.25a-1.rhel5

4. Find the directory of the previous version of mysql, and delete the files and libraries of the old version of mysql

find / -name mysql

The search results are as follows:

find / -name mysql
 
/ var / lib / mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
Delete the corresponding mysql directory
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql
The specific steps are shown in the figure: Find the directory and delete it

Note: /etc/my.cnf will not be deleted after uninstallation, it needs to be deleted manually

rm -rf /etc/my.cnf

5. Find out if mysql is installed on the machine again

rpm -qa|grep -i mysql

6、解压mysql的tar.gz压缩包

tar -xvf mysql-5.6.27-linux-glibc2.5-x86_64.tar.gz

7、复制解压后的mysql目录到系统的本地软件目录

cp mysql-5.6.27-linux-glibc2.5-x86_64 /usr/local/mysql -r

8、设置mysql的用户和用户组,并进行安装

groupadd mysql                             添加系统mysql组
useradd -r -g mysql mysql                  添加mysql用户
cd /usr/local/mysql                          进入mysql目录
chown -R mysql:mysql ./                    修改当前目录拥有者为mysql用户
./scripts/mysql_install_db --user=mysql    安装数据库
chown -R root:root ./                      修改当前目录拥有者为root用户
chown -R mysql:mysql data                  修改当前data目录拥有者为mysql用户

9、添加环境变量

sudo vim /etc/profile

在profile文件的最底部添加以下内容:

#set mysql environment
export MYSQL_HOME=/usr/local/mysql  这里mysql所在的目录
export PATH=$PATH:$MYSQL_HOME/bin
source /etc/profile 使当前文件生效

10、启动mysql服务和添加开机启动mysql服务

cp support-files/mysql.server /etc/init.d/mysql 把启动脚本放到开机初始化目录
service mysql start                             启动mysql服务
ps -ef|grep mysql                               看到mysql服务说明启动成功

11、修改mysql的root用户密码,root初始密码为空的:

./bin/mysqladmin -u root password '123456' 这里把密码设置为123456,在/usr/local/mysql目录下执行此命令

12、配置SSH免密码登录,导入sql数据库文件

ssh-keygen -t rsa 生成私钥与公钥文件(按3次回车键)

假设服务器的IP地址是:103.212.33.50

用浏览器访问www.ip138.com,查看自己电脑的外网IP,例如我的是116.1.79.180

ssh-copy-id 116.1.79.180    /*由服务器(103.212.33.50)发一把公钥给我(116.1.79.180)*/
ssh 103.212.33.50           /*我使用公钥密码登录服务器*/

打开SQLyogEnt软件,新建连接,使用SSH隧道进行登录,登录成功就可以导入数据库文件了。



13、Linux下解压war包的方法:

unzip -oq xm.war -d ROOT   xm.war为要解压的war文件,ROOT为要解压成的目录





Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325419865&siteId=291194637