博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ubuntu16.04系统彻底卸载mysql,并源码免编译重装MySQL的步骤
阅读量:6547 次
发布时间:2019-06-24

本文共 3358 字,大约阅读时间需要 11 分钟。

今天的总结

ubuntu上彻底卸载MySQL或重新安装https://www.jianshu.com/p/974b33873bca#查看是否存在mysql服务service mysql status#查看安装了MySQL的相关软件包dpkg --get-selections | grep mysql#卸载MySQLapt-get remove --purge mysql-*#清除本地残留文件apt autoclean#清除无用依赖包(可选)apt autoremove#删除MySQL残留文件rm -rf /etc/mysql /var/lib/mysql免编译安装MySQL的方法安装必要的依赖包apt-get install libaio1添加mysql用户 解压MySQL安装包[root@localhost ~]# groupadd mysql[root@localhost ~]# useradd -r -g mysql -s /bin/false mysql[root@localhost ~]# mkdir -p /data[root@localhost ~]# cd /data[root@localhost data]# tar zxf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz[root@localhost data]# ln -s mysql-5.7.23-linux-glibc2.12-x86_64 mysql[root@localhost data]# 建立存放日志等目录cd /data/mysql-5.7.23-linux-glibc2.12-x86_64/mkdir logs binlogs run删除旧配置文件rm -rf /etc/my.cnf  /etc/mysql/my.cnf  /usr/local/mysql/etc/my.cnf  ~/.my.cnf新增MySQL的配置文件/etc/my.cnfcat > /etc/my.cnf << EOF[client]default-character-set = utf8mb4port= 3306socket= /data/mysql/run/mysql.sock[mysql]default-character-set = utf8mb4prompt = " \u@\h \R:\m:\s [\d]> "no-auto-rehashsocket= /data/mysql/run/mysql.sock[mysqld]character-set-server = utf8mb4collation-server = utf8mb4_unicode_cicharacter-set-client-handshake = FALSEserver-id = 3306user= mysqlport= 3306basedir= /data/mysqldatadir= /data/mysql/datasocket= /data/mysql/run/mysql.sockpid-file = /data/mysql/run/mysqld.pidskip_name_resolve = 1open_files_limit = 65535back_log = 1024max_connections = 1024log-error = /data/mysql/logs/mysql-error.logEOF初始化MySQL[root@localhost data]# cd /data/mysql[root@localhost mysql]# mkdir mysql-files[root@localhost mysql]# chown mysql:mysql mysql-files[root@localhost mysql]# chmod 750 mysql-files[root@localhost mysql]# chown -R mysql:mysql .[root@localhost mysql]# bin/mysqld --initialize --user=mysql  --basedir=/data/mysql --datadir=/data/mysql/data[root@localhost mysql]# bin/mysql_ssl_rsa_setup --datadir=/data/mysql/dataubuntu的unit file路径/lib/systemd/systemcat > /lib/systemd/system/mysqld.service << EOF[Unit]Description=MySQL ServerDocumentation=man:mysqld(8)Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.htmlAfter=network.targetAfter=syslog.target[Install]WantedBy=multi-user.target[Service]User=mysqlGroup=mysqlType=forkingPIDFile=/data/mysql/run/mysqld.pid# Disable service start and stop timeout logic of systemd for mysqld service.TimeoutSec=0# Execute pre and post scripts as rootPermissionsStartOnly=true# Needed to create system tables#ExecStartPre=/usr/bin/mysqld_pre_systemd# Start main serviceExecStart=/data/mysql/bin/mysqld --daemonize --pid-file=/data/mysql/run/mysqld.pid $MYSQLD_OPTS# Use this to switch malloc implementationEnvironmentFile=-/etc/sysconfig/mysql# Sets open_files_limitLimitNOFILE = 65535Restart=on-failureRestartPreventExitStatus=1PrivateTmp=falseEOF配置MySQL环境变量echo "export PATH=$PATH:/data/mysql/bin" >> /etc/profilesource /etc/profile启动与开机启动MySQLsystemctl daemon-reloadsystemctl start mysqld.servicesystemctl enable mysqld.servicesystemctl is-enabled mysqld用临时密码登录并修改临时密码[root@localhost ~]# grep 'temporary password' /data/mysql/logs/mysql-error.log2018-09-24T07:54:08.055154Z 1 [Note] A temporary password is generated for root@localhost: p=lXlKKrg4GJ[root@localhost ~]# mysql -urrott -p "p=lXlKKrg4GJ"mysql shell > alter user root@'localhost' identified by 'root12#$';mysql shell > \q

 

转载于:https://www.cnblogs.com/FengGeBlog/p/10403122.html

你可能感兴趣的文章
威斯敏斯特教堂地下室里无名碑的格言
查看>>
HDU 3001 Travelling
查看>>
[原创]ExtAspNet秘密花园(十九) — 表格之复选框列
查看>>
Python的web框架很多,比如Django,webpy等,但是哪一种综合实力最强呢?
查看>>
在tomcat下context.xml中配置各种数据库连接池
查看>>
Python数据分析工具包:Pandas
查看>>
C#结构体指针的定义及使用详解
查看>>
ASP.NET AJAX(控件扩展器、工具包详述)
查看>>
ELMAH在ASP.NET MVC中的使用
查看>>
获取Repeter的Item和ItemIndex
查看>>
table极细边框的实现
查看>>
autotools工具使用
查看>>
Mac与VMware虚拟机之间无法复制/粘贴的解决方法
查看>>
.net反射详解
查看>>
ASP.net Web API的模块依赖关系
查看>>
MySQL的表分区
查看>>
不同dll相同Type.FullName引发的问题
查看>>
云计算平台简介(App Engine)
查看>>
servlet过滤器2 解决用户非法在线 filter
查看>>
gene6的几个使用技巧
查看>>