Archive for the ‘mysql’ Category

忘记mysql root密码

备忘一下。

以windows平台、xampp 1.7.3\ MySQL 5.1.41 为例

停掉当前的mysqld服务,也可以直接杀死mysqld.exe进程。

开个cmd,运行 mysqld –safe-mode –skip-grant-tables

再开个cmd, 运行mysql , 因为当前进入的是安全模式,所以不需要任何密码,直接进。

mysql>update user set password=password(‘new_password’) where user=’root’;

mysql>quit

关闭安全模式mysqld,正常启动mysql,root的密码已经修改为 new_password

 

dr.com与apache冲突暂行解决方案

apahce和dr.com(学校用的v3.483(d14)) 的冲突问题让我困顿,每次开机都要禁用windows防火墙,禁用lmhost,netbios,然后再手动开启apache和mysql,我已经被dr.com打败。

方法非原创,参看这里的几篇文章:12

主要是通过修改dr.com和apache冲突了的注册表值,

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\WinSock2\Parameters\
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\

在没有安装dr.com的情况下导出上面两个位置的键值,名为apache1.reg apache2.reg

在安装dr.com的情况下导出上面两个位置的键值,名为drcom1.reg drcom2.reg

写个bat和这些.reg文件全部复制到apache目录 ,我用的是2.2: D:\phpnow\Apache-22

批处理内容————————————————

echo import apache.reg…& restart apache
regedit /s apache1.reg
regedit /s apache2.reg
call D:\phpnow\PnCmds\Apa_Restart.cmd
call D:\phpnow\PnCmds\My_Stop.cmd
call D:\phpnow\PnCmds\My_Start.cmd
echo press enter to import drcom.reg
pause
regedit /s drcom1.reg
regedit /s drcom2.reg

用的时候先开机,正常登陆dr.com,然后运行这个批处理,运行到pause就会提示“按回车键继续…” ,这样就使用了适合apache的键值,然后call了三个bat来启动apache和mysql,phpnow带有这些维护bat, 根据phpnow的安装目录酌情修改。然后,要不是上网了,先退出dr.com 然后bat回车退出。。

我用了这样方法,但是并不能保证所有的程序的网络都正常,firefox,IE,校内通,爱饭,QQ 没有全部都能一起联网的。哎,我在琢磨接下来了版本中是dr.com主动兼容apache,还是apache主动兼容dr.com呢? 我觉得都不可能,因为dr.com不鸟apache,apache也不知道啥是dr.com。


 

WordPress密码忘了的解决办法

wp的密码在存入数据库时 转为md5码
根据此原理我们可以手动update数据库 设置自定的密码
mysql> update wp_users set user_pass = md5(“xxx”) where user_login = “admin”;

wp_users为数据库中的那张用户表
xxx改为你自己的密码  注意这里是你的真是的密码而不是你加密后的密码。。!!

这几天wordpress的使用让我学到了很多mysql的东西 。。THX 。。

 

安装使用mysql操作我网站的数据库

wordpress又出了点问题。就是发布文章的时候没有显示在我的主页上。但是在文章的分类中我还是可以查看到了 所以我想使用 mysql来把数据库重新做过没有办法 谁叫我是菜鸟呢.
安装了 yum就没有这样的费力了
code—————————-
[root@jlinux ~]# yum install mysql-client
Loading “installonlyn” plugin
Existing lock /var/run/yum.pid: another copy is running. Aborting.
很多的时候都会遇到这样的情况。原因很简单 yum是允许同一时间只能有一个进程运行 原理知道了
我就
code——————————–
[root@jlinux ~]# rm -f /var/run/yum.pid
把/var/run/yum.pid给删除了 这样就可以使用了所以以后使用yum的时候一定要正确的退出 而不是ctrl+c

————————————–
[root@jlinux ~]# yum install mysql
Loading “installonlyn” plugin
Setting up Install Process
Setting up repositories
livna

[1/4]
core                                                                 [2/4]
updates                                                              [3/4]
extras                                                               [4/4]
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
–> Populating transaction set with selected packages. Please wait.
—> Downloading header for mysql to pack into transaction set.
mysql-5.0.27-1.fc5.i386.r 100% |=========================|  35 kB    00:01
—> Package mysql.i386 0:5.0.27-1.fc5 set to be updated
–> Running transaction check
–> Processing Dependency: perl(DBI) for package: mysql
–> Restarting Dependency Resolution with new changes.
–> Populating transaction set with selected packages. Please wait.
—> Downloading header for perl-DBI to pack into transaction set.
perl-DBI-1.52-1.fc5.i386. 100% |=========================|  16 kB    00:00
—> Package perl-DBI.i386 0:1.52-1.fc5 set to be updated
–> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
mysql                   i386       5.0.27-1.fc5     updates           3.3 M
Installing for dependencies:
perl-DBI                i386       1.52-1.fc5       updates           605 k

Transaction Summary
=============================================================================
Install      2 Package(s)
Update       0 Package(s)
Remove       0 Package(s)
Total download size: 3.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): mysql-5.0.27-1.fc5 100% |=========================| 1.8 MB    02:18
http://ftp.iij.ad.jp/pub/linux/fedora/core/updates/5/i386/mysql-5.0.27-1.fc5.i386.rpm: [Errno 4] Socket Error: (11, ‘\xe8\xb5\x84\xe6\xba\x90\xe6\x9a\x82\xe6\x97\xb6\xe4\xb8\x8d\xe5\x8f\xaf\xe7\x94\xa8′)
Trying other mirror.
(1/2): mysql-5.0.27-1.fc5 100% |=========================| 3.3 MB    06:17
(2/2): perl-DBI-1.52-1.fc 100% |=========================| 605 kB    01:37
———————————–
下载了 mysql and perl-dbi两个包。。
不知道是原因下载了 这两个包 但是并没有安装 。。
我就来到了 yum的cache目录 /var/cache/yum
我的fedora 5上面有 core  extras  fedora-xgl  livna  updates
这样的目录
core就是必要的软件 extras是额外的 附加的意思 feodra-xgl这个是我以前安装xgl桌面的时候建立的 livna有很多使用的软件 updates就是mysql的包的存放的目录了 。。。
code———————————-
[root@jlinux packages]# pwd
/var/cache/yum/updates/packages
[root@jlinux packages]# rpm -ivh mysql-5.0.27-1.fc5.i386.rpm
Preparing…                ########################################### [100%]
package mysql-5.0.27-1.fc5 is already installed
[root@jlinux packages]# rpm -ivh perl-DBI-1.52-1.fc5.i386.rpm
Preparing…                ########################################### [100%]
package perl-DBI-1.52-1.fc5 is already installed
[root@jlinux packages]#
code———————————————–
安装这两个包
但是安装mysql并没有成功
#mysql -h jlinux -u sq_tunpishuang -p
连接的时候显示
code——————————–
[root@jlinux ~]# mysql -h jlinux.cn -u sq_tunpishuang -p
Enter password:
ERROR 1045 (28000): Access denied for user ’sq_tunpishuang’@'222.183.62.123′ (using password: YES)
[root@jlinux ~]#
code———————————–
解决了 是我的密码错了 呵呵

看到以下的东西就是我们已经成功的进入的MYSQL的 数据库系统
真的是很对不起大家 我用的空间是windows下面的mysql..呵呵 linux 那些都很贵 不是linux的优点是成本低啊
其实不是这样 linux的发行版确实是很便宜 但是犹豫linux的复杂度高  所以网管的工资高了费用当然就高了哦

下面是连接成功的样子 :
code———————————
[root@jlinux ~]# mysql -h 125.65.81.5 -u sq_tunpishuang -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 77045 to server version: 5.2.3-falcon-alpha-communit y-nt

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>
——————————————————–

[root@jlinux ~]# mysql -h jlinux.cn -u sq_tunpishuang -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 77149 to server version: 5.2.3-falcon-alpha-community-nt

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> select version()
-> select version()
-> selet current_dat
-> selet current_data
-> selet current_data
-> selet current_data;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’select version()
selet current_dat
selet current_data
selet current_data
selet c’ at line 2
mysql> use sq_tunpishuang
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables
-> show tables;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’show tables’ at line 2
mysql> show table
-> show table;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’show table’ at line 2
mysql> show tables;
+————————–+
| Tables_in_sq_tunpishuang |
+————————–+
| wp_categories            |
| wp_comments              |
| wp_link2cat              |
| wp_links                 |
| wp_options               |
| wp_post2cat              |
| wp_postmeta              |
| wp_posts                 |
| wp_sticky                |
| wp_usermeta              |
| wp_users                 |
+————————–+
11 rows in set (0.05 sec)

mysql>
可以看到很多的表格了 呵呵
wp_表示我用的是wordpress的php程序;
然后就开始重新作站了

 

ERROR 1045 (28000): Access denied for user

今天第一次做了就是把我的网站的所有的数据库都删除。。因为我上次也说过了把WORDPRESS作为网站的主要程序。。其实我想了一想真的是WORDPRESS的灵活性真的是很强就说开始了吧。我把jlinux.cn/blog 的程序的东西都删除然后下载了一个wordpress2.2的最新的中文版。其实也不叫中文版。是一个汉化版吧。因为wordpress的官方网站(wordpress.com)好想没有语言包之类了。都是国内的一些牛人做的汉化版。。网站的地址是wordpress.org.cn 然后花了N多的时间用flashfxp上传。文件不大但是很多。。真实羡慕那些可以在线解压缩的空间。真是棒极了。呵呵。。最后上传后打开jlinux.cn/index.php出现的东西让我很是吃惊。。简单的最原始的东西。随便点一个连接也是打不开了原因很简单我以前的数据库sq_tunpishuang还没有删除上面的东西还是以jlinux.cn/blog的连接来展示的  然后下一步也就确定了就是删除sq_tunpishuang这个库。。开始在LINUX下没有上网成功。。所以就用了 mysql的 win32版。。在mysql.cn 下载了最新的5.0的版本。。。问题就来了连接的命令是
shell>mysql -h jlinux.cn -u sq_tunpishuang -p (密码)
结果显示这样的提示:
C:\mysql\bin>mysql
ERROR 1045 (28000): Access denied for user ‘ODBC’@'xxxxx’ (using password: N
O)
xxxxx是我现在用的机器的IP。。。这样当然是无法连接。。
我的解决的方法是使用视窗界面的EngInSite MySQL Client客户端。。
ADD CONNECT !!分别添上Friendly name 随便你添什么 HOSTname 就是你要连接的mysql的服务器的地址或者是IP。。。然后PORT一般默认的是3306。。。database是你想要进入哪个你想操作的数据库。。 username password :分别填上你的用户名和密码。。就OK就连接上了。。把我的sq_tunpishuang清空这样我的wordpress就又可以使用了。。