linux卸载源码mysql_linux下mysql数据源码装与卸载

1、mysql卸载

删除/var/lib/mysql下的文件:

[oracle@ogg mysql]$ su -

Password:

[root@ogg ~]# cd /var/lib/mysql/

[root@ogg mysql]# ls

auto.cnf ib_logfile1 mysql-bin.000001 mysql-bin.000004 mysql-bin.000007 ogg.err test

ibdata1 master-log-bin.index mysql-bin.000002 mysql-bin.000005 mysql-bin.000008 ogg.pid

ib_logfile0 mysql mysql-bin.000003 mysql-bin.000006 mysql-bin.index performance_schema

[root@ogg mysql]# rm -rf *

删除/usr/local/mysql下的文件:

[root@ogg mysql]#cd /usr/local/mysql

[root@ogg mysql]# ls

bin data include lib mysql-5.6.4-m7 README share support-files

COPYING docs INSTALL-BINARY man mysql-test scripts sql-bench

[root@ogg mysql]# rm -rf mysql-5.6.4-m7/

[root@ogg mysql]# rm -rf *

2、mysql源码安装

复制解压后的mysql目录到系统的本地软件目录: 执行命令:

cp mysql-5.6.17-linux-glibc2.5-i686 /usr/local/mysql -r

注意:目录结尾不要加/

创建mysql用户:

[root@localhost mysql]# useradd mysql

设置mysql用户密码:

[root@localhost mysql]# echo '123456'|passwd --stdin mysql

设置权限:

[root@localhost mysql]# cd /usr/local

[root@localhost local]# chown -R mysql:mysql mysql/切换到mysql用户

[root@localhost local]# su - mysql

[mysql@localhost ~]$ cd /usr/local/mysql/scripts/安装mysql数据库:

[mysql@localhost scripts]$ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

这里可能会报错:scripts/mysql_install_db: /usr/bin/perl: bad interpreter: No such file or directory。

需要安装perl以及perl-devel.执行命令:yum –y install perl perl-devel

配置文件:

cd /software/mysql-5.6.21/support-files

cp my-default.cnf /etc/my.cnf

cp mysql.server /etc/init.d/mysql

vim /etc/init.d/mysql

#

若mysql的安装目录是/usr/local/mysql,则可省略此步

修改文件中的两个变更值

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

配置环境变量:

vi /etc/profile

export MYSQL_HOME=/usr/local/mysql

export PATH=$MYSQL_HOME/bin:$PATH

保存退出:

source /etc/profile

启动:

[root@localhost mysql]# chkconfig --add mysql

[root@localhost mysql]# chkconfig mysql on

[root@localhost mysql]# service mysql start

Starting MySQL.. SUCCESS!

设置root登录密码:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'

登录:

[mysql@localhost ~]$ mysql -uroot -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.6.30 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>

设置登录权限:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

Query OK, 0 rows affected (0.06 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.04 sec)

mysql>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值