yum -y install libaio
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
cd /usr/local/soft/mysql/src
mkdir ../5.7.24_3306 &&tar -xzvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C ../5.7.24_3306 --strip-components 1
mkdir -p /usr/local/soft/mysql/5.7.24_3306/{run,data,logs,bin_log,sock,cert}
groupadd mysql &&useradd -r -g mysql -s /bin/false mysql
cd /usr/local/soft/mysql/5.7.24_3306/bin &&./mysqld --initialize
--explicit_defaults_for_timestamp
--user=mysql
--basedir=/usr/local/soft/mysql/5.7.24_3306
--datadir=/usr/local/soft/mysql/5.7.24_3306/data
--lc_messages_dir=/usr/local/soft/mysql/5.7.24_3306/share
--lc_messages=en_US
2018-12-01T09:56:45.934627Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-12-01T09:56:46.056837Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-12-01T09:56:46.127141Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 69d028f9-f54f-11e8-9c4a-00163e08e793.
2018-12-01T09:56:46.130249Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-12-01T09:56:46.131377Z 1 [Note] A temporary password is generated for root@localhost: sDdPx3>.,oBi
cd /usr/local/soft/mysql/5.7.24_3306/bin &&./mysql_ssl_rsa_setup --datadir=/usr/local/soft/mysql/5.7.24_3306/cert
修改证书权限为644
cd /usr/local/soft/mysql/5.7.24_3306/bin &&./mysql -uroot -S /usr/local/soft/mysql/5.7.24_3306/sock/mysql.sock
use mysql
update user set host = '%', authentication_string = password('123456') where user = 'root'
select host,user,authentication_string from user
flush privileges
grant all privileges on . to 'root'@'%'
flush privileges
cat >/etc/systemd/system/3306.service <<EOF
[Unit]
Description=MySQL 3306
Documentation= http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/soft/mysql/5.7.24_3306/run/mysql.pid
ExecStart=/usr/local/soft/mysql/5.7.24_3306/support-files/mysql.server start
ExecReload=/usr/local/soft/mysql/5.7.24_3306/support-files/mysql.server restart
ExecStop=/usr/local/soft/mysql/5.7.24_3306/support-files/mysql.server stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl enable 3306.service
1、
cd /usr/local/soft/mysql/5.7.24.3306/bin &&./mysqld_safe --skip-grant-tables &
cd /usr/local/soft/mysql/5.7.24.3306/bin &&./mysqld_safe --skip-grant-tables --skip-networking &
2、
./mysql -uroot -p -S /usr/local/soft/mysql/5.7.24.3306/sock/mysql.sock
3、
use mysql
update mysql.user set authentication_string=password('123456') where user='root'
flush privileges
mkdir -p /usr/local/soft/mysql/back/5.7.23_3306 &&cp -Rf /usr/local/soft/mysql/5.7.23_3306/* /usr/local/soft/mysql/back/5.7.23_3306
mkdir -p /usr/local/soft/mysql/back/5.7.24_3306 &&cp -Rf /usr/local/soft/mysql/5.7.24_3306/* /usr/local/soft/mysql/back/5.7.24_3306
CREATE USER 'sdyc'@'%' IDENTIFIED BY '123456'
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON sd_data.* TO 'sdyc'@'%'
GRANT SELECT, INSERT, UPDATE, DELETE, EXECUTE ON card_data.* TO 'sdyc'@'%'
SHOW GRANTS FOR sdyc
CREATE USER 'back'@'localhost' IDENTIFIED BY '123456'
GRANT SELECT, RELOAD, PROCESS, SHOW DATABASES, SUPER, LOCK TABLES, REPLICATION CLIENT ON . TO 'back'@'localhost'
SHOW GRANTS FOR back
REVOKE SELECT, INSERT, UPDATE, DELETE, EXECUTE ON sd_data.* FROM 'sdyc'@'%'
1.新建excel表格,准备录入自己的数据。
2.录入要导入的数据,注意要与数据库的类型一致。
3.另存为txt文档,记得自己的命名。
4.打开txt文档,点击另存为,修改编码,解决中文utf8。
5.打开mysql命令行,输入如下命令,注意文件位置,数据库表。
打开cmd(记得”使用管理员身份“打开),如果没有配置环境变量,请cd(切换目录)到mysql程序下的bin文件夹下 执行命令 D:\mysql\mysql-5.7.29-winx64\bin "MySql"为服务名称,你的MysSql服务不一定是这个名称,可以打开电脑的服务窗口查看。 删除完成之后,最好去电脑的服务窗口看下,如果找不到MySql服务,说明已经已经删除成功。 如果还能看到MySql服务,可以手动右击选择”停止“,服务停止之后就会自动消失了。 在mysql程序的根目录下,新建一个my.ini空白文件,用记事本打开,将以下内容复制进去 # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_bin init_connect='SET NAMES utf8mb4' # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. basedir = D:\MySQL datadir = D:\MySQL\data port = 3306 # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 16M read_rnd_buffer_size = 16M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES其中basedir 和 datadir 根据实际MySql安装的位置进行修改。 删除之前生成的data文件,如果有重要的数据表,请先备份好。 回到cmd,重新生成data文件。在bin目录下运行: mysqld --initialize-insecure --user=mysql安装MySql服务,同时设置绑定my.ini配置文件。命令: mysqld --install"MySql" --defaults-file="d:/mysql/my.ini" “MySql”是服务名称,80表示8.0版本,当然,也可以自己取别的名字。 ”..\my.ini“是新建的配置文件的位置,也可以写成绝对路径”D:\MySql\my.ini“。 如果提示安装成功,这时打开电脑的”服务“窗口,可以找到新添加的MySql80服务: 这里有两种启动服务的方式:1)服务窗口启动;2)cmd启动 cmd方式:bin目录下执行命令 net start mysql 如果启动不成功 这时可能是my.ini配置文件中的某些配置有问题。你可以修改ini文件内容,然后从头按步骤再试一遍。 删除了data文件和服务之后,之前的密码就失效了,所以需要重新设置密码。 bin目录下执行命令 mysql -u root -p 这时密码为空,不需要填写,直接回车: 如果这里没有登陆成功 (敲黑板)这里有个需要注意的地方,在8.0之后的版本,修改root用户密码的命令是: ALTER USER'root'@'localhost'IDENTIFIED WITH mysql_native_password BY'你的密码' 之前的版本是: update mysql.usersetauthentication_string=password("你的密码")whereuser="root" 命令:mysql>exit 这里的命令和之前是一样的,就不写了,密码记得要填刚才设置的 如果修改后,重启服务报错 有一种可能:你修改的配置与服务初始化时的配置有冲突,这时只能从头开始,在初始化的时候绑定my.ini文件 。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)