[root@beyond ~]# useradd -M -s /sbin/nologin MysqL
解压并释放源代码:
[root@beyond mnt]# tar zxvf MysqL-5.0.56.tar.gz -C /usr/src/
要是配置编译不了,就配置yum源
安装下面的软件;
[root@beyond MysqL-5.0.56]# yum install *vim*
[root@beyond MysqL-5.0.56]# yum install -y *termcaP*
配置编译;
[root@beyond MysqL-5.0.56]# ./configure --prefix=/usr/local/apache2
Remember to check the platform specific part of the reference manual for
hints about installing MysqL on your platform. Also have a look at the
files in the Docs directory.
Thank you for choosing MysqL!
编译并安装;
[root@beyond MysqL-5.0.56]# make && make install
2.建立配置文件;
[root@beyond MysqL-5.0.56]# cp support-files/my-medium.cnf /etc/my.cnf
初始化数据库;
[root@beyond MysqL-5.0.56]# /usr/local/MysqL/bin/MysqL_install_db --user=MysqL
[root@beyond MysqL-5.0.56]# chown -R root.MysqL /usr/local/MysqL/
[root@beyond MysqL-5.0.56]# chown -R MysqL /usr/local/MysqL/
调整lib库路径:
[root@beyond MysqL-5.0.56]# echo "/usr/local/MysqL/lib/MysqL" >> /etc/ld.so.conf
[root@beyond MysqL-5.0.56]# ldconfig
MysqL启动控制;
[root@beyond MysqL-5.0.56]# /usr/local/MysqL/bin/MysqLd_safe --user=MysqL &
[root@beyond MysqL-5.0.56]# netstat -ntpl | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 23437/MysqLd
[root@beyond MysqL-5.0.56]# cp support-files/MysqL.server /etc/init.d/MysqLd
[root@beyond MysqL-5.0.56]# chmod +x /etc/init.d/MysqLd
[root@beyond MysqL-5.0.56]# chkconfig --add MysqLd
[root@beyond MysqL-5.0.56]# chkconfig MysqLd on
设置MysqL程序的执行路径;
[root@beyond MysqL-5.0.56]# export PATH=$PATH:/usr/local/MysqL/bin/
[root@beyond MysqL-5.0.56]# echo "PATH=$PATH:/usr/local/MysqL/bin" >> /etc/profile
[root@beyond ~]# MysqL -u root
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 1
Server version: 5.0.56-log Source distribution 退出;exit
[root@beyond ~]# MysqLadmin -u root password "123.com"
[root@beyond ~]# MysqL -u root -p
Enter password:
数据库结构,
MysqL> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| @R_24_4045@ion_schema |
| MysqL |
| test |
+--------------------+
3 rows in set (0.00 sec)
Database changed
MysqL> SHOW TABLES;
+---------------------------+
| Tables_in_MysqL |
+---------------------------+
| columns_priv |
| db |
| func |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| proc |
| procs_priv |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
17 rows in set (0.00 sec)
MysqL> CREATE DATABASE beyond;
Query OK,1 row affected (0.00 sec)
MysqL> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| @R_24_4045@ion_schema |
| beyond |
| MysqL |
| test |
+--------------------+
4 rows in set (0.00 sec)
MysqL> DROP DATABASE taotao;
Query OK,0 rows affected (0.00 sec)
创建和删除数据表;
MysqL> CREATE TABLE songs (songs_name CHAR(30) NOT NULL,songs_passwd CHAR(20) NOT NULL DEFAULT '123.com',PRIMARY KEY (songs_name));
Query OK,0 rows affected (0.02 sec)
插入新的数据记录;
MysqL> INSERT INTO auth.users(user_name,user_passwd) VALUES('huangjiajv',ENCRYPT('123456'));
Query OK,1 row affected (0.01 sec)
MysqL> INSERT INTO auth.users(user_name,user_passwd) VALUES('huangguanzhong',ENCRYPT('com.123'));
Query OK,1 row affected (0.00 sec)
修改数据表信息;
MysqL> UPDATE auth.users SET user_passwd=ENCRYPT('123.com') WHERE user_name='taotao';
Query OK,0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
数据库的备份和恢复;
[root@www ~]# MysqLdump -u root -p auth > MysqL-auth.sql
Enter password:
[root@www ~]# ll MysqL-auth.sql
-rw-r--r-- 1 root root 1863 Dec 30 01:01 MysqL-auth.sql //备份数据库;
Database changed
MysqL> DROP DATABASE auth;
Query OK,1 row affected (0.01 sec)
查看一下是否删除;
MysqL> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| @R_24_4045@ion_schema |
| beyond |
| MysqL |
| test |
+--------------------+
4 rows in set (0.00 sec)
[root@www ~]# MysqL -u root -p auth < MysqL-auth.sql
Enter password:
[root@www ~]# MysqLdump -u root -p beyond > /usr/src/MysqL-beyond.sql
Enter password:
[root@www ~]# ll /usr/src/MysqL-beyond.sql
-rw-r--r-- 1 root root 1775 Dec 30 02:00 /usr/src/MysqL-beyond.sql
[root@www ~]# MysqL -u root -p beyond < /usr/src/MysqL-beyond.sql
Enter password:
[root@www ~]#
备份某个数据库中的某个表;
[root@www ~]# MysqLdump -u root -p MysqL host user > MysqL.host-user.sql
Enter password:
[root@www ~]#
刚装了MysqL
sudo apt-get install MysqL
安装成功了,安装最后要求输入了密码,也输入了,OK
MysqL -uroot -p
输入设置的密码
竟然报错了!
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YSE)
密码留空
还是错误!
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
于是重改密码!
#sudo /etc/init.d/MysqL stop
# MysqLd_safe --user=MysqL --skip-grant-tables --skip-networking &
MysqL> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
MysqL> FLUSH PRIVILEGES;
MysqL> quit
# /etc/init.d/MysqL restart
# MysqL -u root -p
Enter password:
搞定!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。