mysql tar centos7

vim/etc/my.cnf

[client]

port=3306

socket=/ddhome/bin/mysql/tmp/mysql.sock

[mysql]

#设置mysql客户端默认字符集

default-character-set=utf8

[mysqld]

#skip-grant-tables

character_set_server=utf8

init_connect='SETNAMESutf8'

skip-name-resolve

#设置3306端口

port=3306

#设置mysql的安装目录

basedir=/usr/local/mysql/

#设置mysql数据库的数据的存放目录

datadir=/ddhome/bin/mysql/data

#允许最大连接数

max_connections=200

#服务端使用的字符集默认为8比特编码的latin1字符集

character-set-server=utf8

#创建新表时将使用的默认存储引擎

default-storage-engine=INNODB

lower_case_table_names=1

max_allowed_packet=16M

log-error=/ddhome/bin/mysql/log/mysqld.log

pid-file=/ddhome/bin/mysql/data/mysqld.pid

socket=/ddhome/bin/mysql/tmp/mysql.sock

rpm-qimysql-server

rpm-qa|grep"mysql"

rpm-qa|grepmariadb

rpm-e--nodepsmariadb-libs-5.5.56-2.el7.x86_64

rm/etc/my.cnf

rpm-qa|grepmysql

cat/etc/group|grepmysql

cat/etc/passwd|grepmysql

groupaddmysql

useradd-gmysqlmysql

passwdmysql

#由于我的/usr/local空间不足,所以我安装到/var

[root@hdp265dnsnfsvar]#tar-zxvfmysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

[root@hdp265dnsnfsvar]#mvmysql-5.7.18-linux-glibc2.5-x86_64/mysql57

#更改所属的组和用户

chgrp-Rmysql/usr/local/mysql/

chown-Rmysql/usr/local/mysql/

cd/usr/local/mysql/

chown-Rmysql:mysql/ddhome/bin/mysql/

chown-Rmysql:mysql/ddhome/bin/mysql/data/

vim/etc/my.cnf

[mysqld]

character_set_server=utf8

init_connect='SETNAMESutf8'

basedir=/usr/local/mysql

datadir=/ddhome/bin/mysql/data

socket=/tmp/mysql.sock

#不区分大小写(sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES这个简单来说就是sql语句是否严格)

lower_case_table_names=1

log-error=/ddhome/bin/mysql/log/mysqld.log

pid-file=/ddhome/bin/mysql/data/mysqld.pid

[mysql]

#设置mysql客户端默认字符集

default-character-set=utf8

[mysqld]

skip-name-resolve

#设置3306端口

port=3306

#设置mysql的安装目录

basedir=/usr/local/mysql/

#设置mysql数据库的数据的存放目录

datadir=/ddhome/bin/mysql/data

#允许最大连接数

max_connections=200

#服务端使用的字符集默认为8比特编码的latin1字符集

character-set-server=utf8

#创建新表时将使用的默认存储引擎

default-storage-engine=INNODB

lower_case_table_names=1

max_allowed_packet=16M

chmod777/ddhome/bin/mysql/

ERROR2002(HY000):Can'tconnecttolocalMySQLserverthroughsocket'/ddhome/bin/mysql/tmp/mysql.sock'(2)

chown-Rmysql:mysql/usr/local/mysql/

chown-Rmysql:mysql/ddhome/bin/mysql/

ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:YES)

mysqld_safe--user=mysql--skip-grant-tables--skip-networking&

vim/etc/my.cnf

skip-grant-tables

mysql-urootmysql

UPDATEuserSETPassword=PASSWORD('dd@2018')whereUSER='root';

updateusersetauthentication_string=PASSWORD("dd@2018")whereuser='root';

ps-ef|grepmysqld

ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstatementbeforeexecutingthisstatement.

alteruser'root'@'localhost'identifiedby'root';

cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld

vim/etc/init.d/mysqld

servicemysqldstart

chkconfig--addmysqld

chkconfigmysqldon

ln-s/usr/local/mysql/bin/mysql/usr/bin

cat/root/.mysql_secret

mysqladmin-uroot-p

mysql-uroot-p

updateusersetauthentication_string=PASSWORD("dd@2018")whereuser='root';

alteruser'root'@'localhost'identifiedby'root';

flushprivileges;

GRANTALLPRIVILEGESON*.*TO'root'@'%'IDENTIFIEDBY'dd@2018'WITHGRANTOPTION;

mysqld--initialize--user=mysql--basedir=/usr/local/mysql--datadir=/ddhome/bin/mysql/data/

mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/ddhome/bin/mysql/data/

mysql_ssl_rsa_setup--datadir=/ddhome/bin/mysql/data/

cp./support-files/mysql.server/etc/init.d/mysqld

chown777/etc/my.cnf

chmod+x/etc/init.d/mysqld

/etc/init.d/mysqldrestart

chkconfig--level35mysqldon

chkconfig--listmysqld

chmod+x/etc/rc.d/init.d/mysqld

chkconfig--addmysqld

chkconfig--listmysqld

servicemysqldstatus

exportPATH=$PATH:/usr/local/mysql/bin

SETPASSWORDFOR'root'@'localhost'=PASSWORD('dd@2018');

1、安装mysql

wgethttps://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz#下载mysql

tarzxvfmysql-5.7.22-linux-glibc2.12-x86_64.tar.gz#解压mysql文件

cpmysql-5.7.22-linux-glibc2.12-x86_64/usr/local/mysql-r#复制解压后的mysql目录到系统的本地软件目录

groupaddmysql#创建mysql组

useraddmysql-gmysql#创建mysql用户并添加到mysql用户组

pwd#当前目录/usr/local/mysql

chown-Rmysql.#修改mysql所属用户

chgrp-Rmysql.#修改mysql所属组

cd/usr/local/mysql/bin

yuminstalllibaio

./mysqld--user=mysql--basedir=/usr/local/mysql--datadir=/ddhome/bin/mysql/data#data目录没有就创建(用mysql用户),另外mysql_install_db这个命令已经废了换成了mysqld

ln-s/usr/local/mysql/bin/mysql/usr/bin/mysql#创建mysql快捷方式

servicemysqlstart#启动mysql服务

servicemysqlstop#停止mysql服务

servicemysqlrestart#重启mysql服务

netstat-anp|grepmysqld#查看mysql服务

mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/ddhome/bin/mysql/data

2、接下来就是登陆了

因为是首次登陆,这里笔者使用的方式是

cat/root/.mysql_secret#这个是root首次登陆mysql的初始密码

mysql-uroot-p密码

SETPASSWORDFOR'root'@'localhost'=PASSWORD('dd@2018');#修改数据密码  

GRANTALLPRIVILEGESON*.*TOroot@localhostIDENTIFIEDBY"dd@2018";

3、设置远程客户端登陆

mysql>GRANTALLPRIVILEGESON*.*TO'root'@'192.168.0.0'IDENTIFIEDBY'123456'WITHGRANTOPTION;

mysql>FLUSHPRIVILEGES;

wget-i-chttp://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

相关推荐