Rumah > Artikel > pangkalan data > Mysql安装和环境变量设置及破解密码
1、mysql安装
#usedel mysql
#groupdel mysql
#groupadd mysql
#useradd -g mysql mysql
#tar -zxvf mysql-5.1.55.tar.gz
#cd mysql-5.1.55
#./configure \
#>—prefix=/program/mysql \ //安装路径
#>—localstatedir=/var/lib/mysql \ //数据库文件存放路径
#>—with-comment=Source \
#>—with-server-suffix=-Community \
#>—with-mysqld-user=mysql \
#>—without-debug \
#>—with-big-tables \
#>—with-charset=utf8\
#>—with-collation=utf8_unicode_ci \
#>—with-extra-charsets=all \
#>—with-pthread \
#>—enable-static \
#>—enable-thread-safe-client \
#>—with-client-ldflags=-all-static \
#>—with-mysqld-ldflags=-all-static \
#>—enable-assembler \
#>—without-innodb \
#>—with-innodb \
#>—without-isam \
#>—without-ndb-debug \
#>—with-unix-socket-path=/var/lib/mysql/mysql.sock
#make && make install
#cp ./support-files/my-medium.cnf /etc/my.cnf
#/usr/local/mysql/bin/mysql_install_db —user=mysql
#chown mysql:mysql -R /usr/local/mysql
#chgrp -R mysql /usr/local/mysql
#/usr/local/mysql/bin/mysqld_safe —user=mysql &
#chmod +x ./support-files/mysql.server
#cp ./support-files/mysql.server /etc/init.d/mysqld
#chkconfig –add mysqld
#chkconfig –level 2345 mysqld on
#service mysqld restart
#/usr/local/mysql/bin/mysqladmin -uroot password “new_pass” //修改root用户密码
#netstat -nplt |grep mysql //查看mysql监听端口的信息
#ps -aux |grep mysql //查看mysql运行的进程信息
2、mysql密码恢复
#service mysqld stop
#killall -TERM mysqld
#/usr/local/mysql/bin/safe_mysqld —skip-grant-tables &
#/usr/local/mysql/bin/mysq/mysql
>use msyqlmysql
>upadate user set password=password(“new_pass”) where user=”root”;
>flush privileges;
>exit
#service mysqld start#mysql -uroot -p //如果提示输入密码表明破解密码成功完成;
3、mysql环境变量的设置:
第一种:
#export PATH=$PATH:/usr/local/mysql/bin/
#export //查看环境变量
第二种:
#vi /etc/profileexport PATH=”$PATH:文件路径” //通过配置文件修改环境变量(需要注销系统才能生效)
#env //查看环境变量
第三种:
#vi /root/.bashrcexport PATH=”$PATH:文件路径” //修改root用户的环境变量(需要注销系统才能生效)
#echo $PATH //查看环境变量