Linux Centos7安装MySQL5.5(二进制方式安装)
admin
2023-05-01 10:04:13
0

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;

相关内容

热门资讯

美媒又想起这茬:2年前在地中海... 【文/观察者网 阮佳琪】2024年12月23日,载有16名船员的俄罗斯“大熊星座”号货船在西班牙近海...
App过度索取授权或被境外间谍... 微信公众号“国家安全部”5月13日发文: 手机里各种各样的应用程序(APP)五花八门,在方便我们生...
广合科技获得发明专利授权:“一... 证券之星消息,根据天眼查APP数据显示广合科技(001389)新获得一项发明专利授权,专利名为“一种...
华尔街科技老将:大科技公司分化... 5月11日,互联网泡沫时期的知名芯片分析师、Niles Investment Management创...
香港80后“地产女王”烧炭身亡... 据《香港01》报道,5月12日,香港九龙传统豪宅地段加多利山畔的豪宅项目Kadoorie Hill发...
谷歌发布安卓 AI 系统,这就... 和去年一样,在正式的 Google I/O 开发者大会之前,谷歌为 Android 单独开了一次小型...
300斤医生走红 曾一年猛涨1...   300斤医生走红 曾一年猛涨100斤  【300斤医生走红 曾一年猛涨100斤】5月11日,上海...
新乡市主要负责同志职务调整 日前,中共河南省委决定:魏建平同志任中共新乡市委书记,李卫东同志不再担任中共新乡市委书记、常委、委员...
九阳电饭锅H01故障 H01是因为上盖异常高温,有可能是机板不良造成的;同时也可能是故障前没有清洗上盖或溢出米浆等情况造成...
电饭煲显示e3是什么原因 1、可能是电饭煲里面的食物水分烧干之后,密封圈在高温运转的环境下被烧焦了,这个情况下可能会出现故障提...