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  //查看環境變量

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *