Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-08-15 04:07:01
Point:500 Replies:10 POST_ID:828748USER_ID:11059
Topic:
PHP Scripting Language;Linux;MySQL Server
I go to root mysql like this
mysql>Show databasese
------------------
Database
-----------------
memberlist
phonelist
wordpress-wp
------------------
So there are three databases, First two databases that is okay which
I used phpmyadmin in Cpanel to create them and I can access those two database
by the following php code but fail on database of "wordpress-wp";
Now I expired Cpanel , so I could not use CPanel any more, so I need to use shell command to create my wordpress-wp that is okay & I can access & use it on wordpress software .
But when I try access the database of wordpress-wp using following php
cod ing , that is not working even I already grant access right for my user account
on wordpress-wp, I can not pass the mysql_select_db("wordpress-wp"), Why ?
So I go recheck again at mysql with command Show Grants for myloginname
that also show I have right on the database , wordpress-wp
Now I can see my database is there at /var/lib/mysql but my.cnf file is emtry
at /etc/ so, could you also tell where is mysql config setup file in which
I can see mysql will go to locate the database to /var/lib/mysql ?
Pleae advise, and mysql_connect is no issue at all and I can access wordpress-wp at
linux shell and passed "use wordpress-wp" & "Select * from wp_posts where 1"
I guess that is related path redirect or alias issue on linux , and actual mysql
database path might Not be at /var/lib/mysql but I could NOt find out the solution
of this thread
Duncan
mysql>Show databasese
------------------
Database
-----------------
memberlist
phonelist
wordpress-wp
------------------
So there are three databases, First two databases that is okay which
I used phpmyadmin in Cpanel to create them and I can access those two database
by the following php code but fail on database of "wordpress-wp";
Now I expired Cpanel , so I could not use CPanel any more, so I need to use shell command to create my wordpress-wp that is okay & I can access & use it on wordpress software .
But when I try access the database of wordpress-wp using following php
cod ing , that is not working even I already grant access right for my user account
on wordpress-wp, I can not pass the mysql_select_db("wordpress-wp"), Why ?
So I go recheck again at mysql with command Show Grants for myloginname
that also show I have right on the database , wordpress-wp
Now I can see my database is there at /var/lib/mysql but my.cnf file is emtry
at /etc/ so, could you also tell where is mysql config setup file in which
I can see mysql will go to locate the database to /var/lib/mysql ?
Pleae advise, and mysql_connect is no issue at all and I can access wordpress-wp at
linux shell and passed "use wordpress-wp" & "Select * from wp_posts where 1"
I guess that is related path redirect or alias issue on linux , and actual mysql
database path might Not be at /var/lib/mysql but I could NOt find out the solution
of this thread
Duncan
<?php $link = mysql_connect(http://mysite.com:3306, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db("wordpress-wp"); if(!$db) { die("Unable to select database"); } 1:2:3:4:5:6:7:8:9:
?>"
Expert: julianH replied at 2024-08-15 06:08:04
Yes that would explain it you could also have tried this
Otherwise you are welcome and thanks for the points.
Author: duncanb7 replied at 2024-08-15 05:48:08
The wordpress login is created at mysql with "@localhost"
The userlogin is created by adduser for SSH shell
change from
define("DB_HOST", "http:mysite.com:3306");
to
define("DB_HOST", "localhost:3306");
that is working and wordpress-wp is accesed by mysql_select_db in php coding
Thanks
The userlogin is created by adduser for SSH shell
change from
define("DB_HOST", "http:mysite.com:3306");
to
define("DB_HOST", "localhost:3306");
that is working and wordpress-wp is accesed by mysql_select_db in php coding
Thanks
Author: duncanb7 replied at 2024-08-15 05:34:52
mysql>GRANT ALL PRIVILEGES ON wordpress-wp TO userlogin@localhost IDENTIFIED BY 'password'
Author: duncanb7 replied at 2024-08-15 05:31:18
different password and login
But I already grant the right for my userlogin and wordpresslogin account on "wordpress-wp"
But I already grant the right for my userlogin and wordpresslogin account on "wordpress-wp"
Accepted Solution
Expert: julianH replied at 2024-08-15 05:20:02
500 points EXCELLENT
Are you using the same credentials in your PHP script as you have set in your wp-config file?
Author: duncanb7 replied at 2024-08-15 05:16:57
I 'm using following code to get number of database for my loginname
$db_list = mysql_list_dbs($link);
$i = 0;
$cnt = mysql_num_rows($db_list);
while ($i < $cnt) {
echo mysql_db_name($db_list, $i) . "<br>";
$i++;
}
the result is two
memberlist
phonelist
And no show with "wordpress-wp"
all three is list(ls -la) at /var/lib/mysql
$db_list = mysql_list_dbs($link);
$i = 0;
$cnt = mysql_num_rows($db_list);
while ($i < $cnt) {
echo mysql_db_name($db_list, $i) . "<br>";
$i++;
}
the result is two
memberlist
phonelist
And no show with "wordpress-wp"
all three is list(ls -la) at /var/lib/mysql
Author: duncanb7 replied at 2024-08-15 05:05:15
OR mysql need to update database list for http request ?
I run the php code on browser and on linux shell running the php code
that is also NOT working
Or OR mysql need to update database list for php,ini ?
I run the php code on browser and on linux shell running the php code
that is also NOT working
Or OR mysql need to update database list for php,ini ?
Author: duncanb7 replied at 2024-08-15 05:02:37
I try to netstat -tapn and
the port of 3306 is active or listen, of course, since first two database is accesed
and it is using mysqld not mysql
the port of 3306 is active or listen, of course, since first two database is accesed
and it is using mysqld not mysql
Author: duncanb7 replied at 2024-08-15 04:59:23
Yes,
I can access wordpress software with database of "wordpress-wp"
I can access mysql throught linux shell and use wordpress-wp database
for example
mysql>USE wordpress-wp
.....
mysql>Select * from wp_posts where 1;
--- showing all result
But I can not use in the php coding and report me error as Uable to select database
$db = mysql_select_db("wordpress-wp");
if(!$db) {
die("Unable to select database");
}
I can access wordpress software with database of "wordpress-wp"
I can access mysql throught linux shell and use wordpress-wp database
for example
mysql>USE wordpress-wp
.....
mysql>Select * from wp_posts where 1;
--- showing all result
But I can not use in the php coding and report me error as Uable to select database
$db = mysql_select_db("wordpress-wp");
if(!$db) {
die("Unable to select database");
}
Expert: julianH replied at 2024-08-15 04:45:52
So you are saying the posted code fails but you can still access the site through Word Press - is that correct?