开发者

Setting Default Database in Root Directory

This may be an insanely easy thing to do, but I'm completely lost. I'm working off of a server which is currently hosting two websites: the older site, and the newer wordpress site. The default database on the server is currently for the older site and I'm trying to figure out how to switch it so that the wordpress database is the default, and开发者_高级运维 that site displays instead of the old one. I have access to the server and can login through mysql, but am not sure where to go from there. Any help?


To set a default database on MySQL, you need to add the following lines to your /etc/mysql/my.cnf:

#Setting the default database
[client] 
database = the_desired_database_name

Or to keep things more organized you can create a new file at /etc/mysql/conf.d/ with a .cnf extension (it will be loaded the same way my.cnf does, when the server is started). In my case I created the following /etc/mysql/conf.d/default_database.cnf and added the content I showed you before.

Don't forget to restart Apache after creating the new .cfn file or editing your my.cfn.

Testing: now when you start MySQL on a terminal, your default database should be already selected (no 'USE' statement required at first).

$ mysql -u username -p
$ show tables;

And about your wordpress more specific situation, you said:

I'm trying to figure out how to switch it so that the wordpress database is the default, and that site displays instead of the old one. [...]

As far as I can see, there is no relation between the default database and the default displayed website. Changing the default database will not make your new website being served by default to your visitors.

If it applies to you, try to change the database your wordpress website is using by editing the wp_config.php. Or maybe change your /www root directory to the location of your new site.

Hope it helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜