温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Linux Centos7安装MySQL5.5(二进制方式安装)

发布时间:2020-06-06 14:32:09 来源:网络 阅读:8165 作者:Qiu_CJ 栏目:MySQL数据库

Linux Centos7安装MySQL5.5(二进制方式安装)

一、在/app目录下下载mysql-5.5.54-linux2.6-x86_64.tar.gz`

[root@test /]# cd /app
[root@test app]# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.54-linux2.6-x86_64.tar.gz

二、解压mysql-5.5.54-linux2.6-x86_64.tar.gz

[root@test app]# ta zvxf mysql-5.5.54-linux2.6-x86_64.tar.gz

三、将解压后的mysql-5.5.54-linux2.6-x86_64改名为mysql

[root@test app]# mv mysql-5.5.54-linux2.6-x86_64 mysql

四、添加/etc/my.cnf文件

[root@test app]# cd /app/mysql/support-files/
[root@test support-files]# cp -f my-small.cnf /etc/my.cnf

五、创建mysql目录下的data目录

[root@test support-files]# mkdir -p /app/mysql/data/

六、将mysql的所属用户改为mysql

[root@test support-files]# chown -R mysql.mysql /app/mysql/

七、增加/etc/init.d/mysqld,并为之赋予执行权限,然后初始化MySQL

[root@test support-files]# cp -f mysql.server /etc/init.d/mysqld
[root@test support-files]# chmod +x /etc/init.d/mysqld

【初始化MySQL】

[root@test support-files]# /app/mysql/scripts/mysql_install_db --basedir=/app/mysql --datadir=/app/mysql/data --user=mysql

八、将 /application/mysql/bin/mysqld_safe和/etc/init.d/mysqld中的/usr/local/mysql改为/app/mysq

[root@test support-files]# sed -i 's#/usr/local/mysql#/app/mysql#g' /app/mysql/bin/mysqld_safe /etc/init.d/mysqld

九、启动mysql

[root@test support-files]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/app/mysql/data/test.err'.
.. SUCCESS! 

十、检查mysql是否启动

[root@test support-files]# netstat -lntup | grep mysql
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      5478/mysqld 

十一、设置环境变量

[root@test support-files]# echo 'export PATH=/app/mysql/bin:$PATH' >>/etc/profile
[root@test support-files]# source /etc/profile

十二、进入mysql

[root@test support-files]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.54 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

十三、修改root密码

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

十四、退出MySQL,使用用户名和密码再次登录MySQL

mysql> Ctrl-C -- exit!
Aborted
[root@test support-files]# mysql -uroot -p
Enter password: 

十五、创建数据库和表(指定utf-8编码格式)

mysql> create database userInfo DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

mysql> use userInfo;
Database changed

mysql> create table test (
    -> name varchar(10) not null,
    -> address varchar(100) default null)
    -> ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Query OK, 0 rows affected (0.06 sec)

十六、导入sql文件(若需要执行此步骤)

mysql> source /app/cloud_note.sql
mysql> show databases;
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI