Click to See Complete Forum and Search --> : connect database in mysql
cyh781s
01-24-2003, 03:45 PM
I have a question. mysql works fine in my linux. the only problem is, i have to connect database everytime i want to use it.
here is the copy of mysql status:
mysql> status
--------------
mysql Ver 11.18 Distrib 3.23.54, for pc-linux (i686)
Connection id: 17
Current database:
Current user: root@localhost
Current pager: stdout
Using outfile: ''
Server version: 3.23.54
Protocol version: 10
Connection: Localhost via UNIX socket
Client characterset: latin1
Server characterset: latin1
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 5 hours 33 min 23 sec
Threads: 1 Questions: 51 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 0.003
--------------
you see the Current database is empty.
i know i can use mysql> USE name of database or mysql> CONNECT name of database to connect the database. But then the problem is, I can do this when i am root user, i cannot connect my database when i am not root. is there a way to set it connect to one database when i want to use it by default? thanks
JRefL5
01-24-2003, 03:56 PM
Have you tried
>mysql -p databasename
?
cyh781s
01-24-2003, 04:08 PM
it works.
thanks for replying me so quickly :)
i did a lot of research about this but didn't find anyone or any article talk about "mysql -p databasename", most of them are "mysql -p" or "mysql -u root -p".
but I guess this is common sense for mysql user.
again, thanks for help.
JRefL5
01-24-2003, 04:22 PM
Not a problem.
I've been playng with mysql for a month or 2 trying to get it to do what I want it to do.
jhc
I get the following error after trying to change the password
./bin/mysqladmin -p root
enter password: xxxxxx
./bin/mysqladmin: connect to server at localhost failed
can't connect the server to socket
check that mysql is running and that the socket
/tmp/mysql.sock exixts
I'm stuck... how to change password when I can't get the server up?
TIA
re-v
Originally posted by re-v
I get the following error after trying to change the password
./bin/mysqladmin -p root
enter password: xxxxxx
./bin/mysqladmin: connect to server at localhost failed
can't connect the server to socket
check that mysql is running and that the socket
/tmp/mysql.sock exixts
I'm stuck... how to change password when I can't get the server up?
TIA
re-v It's bad etiquette to hijack someone else's thread.
* presuming you installed the databases successfully with ./mysql_install_db, start the server as indicated in the manual i.e. something like ./safe_mysqld --u user_name -h host_ip/name -p.
* AFAIK mysqladmin can be used only to shutdown the server, not start it.
* Check if the user installing &/ starting MySQL has the permission to write to /tmp/mysql.sock
hth
theN
fepuras
01-28-2003, 04:34 PM
The best way to log in to a mysql server is by name/pass:
mysql -u USERNAME -p
You will be prompted to enter the password. But you will find detailed instructions in mysql manual supplied with your distro.
Have fun using it , I already have.
NOTE:
myself I share the same database(s) for Linux and Windoze for mysql and it works , so far , great. I don't see any problems. Also , the web service shares the same root for Linux and Windoze. I think that's a great way to work wheter youre in Lin or Win.
fepuras
01-28-2003, 04:39 PM
The most probable cause is that your datadir for mysql is not set correctly. But , it also can be the fact that the server is down. If you use RedHat 8.0 , you can use Start ->Server Settings->Services , check in the list if mysqld is configured to run at start, you can also start the service from in there.
Also , you can check if the server is running by typing in console , for example :
mysqladmin version
If you have error that means either you have a bad entry in /etc/my.cnf either service is not started.
Check that file and make sure all your settings are correct.
Thanks for your response
I've tried to download mysql twice from their site. I've tried both the binary and source.
The source has the same set-up. I type
#./configure
and I get among other things a message saying the server and it's settings are already
configured.
The manual at 2.1 says that the prefered method of installation on linux is RPM.
Has anyone set up mysql using the tar.gz approach?
re-v
Originally posted by re-v
Has anyone set up mysql using the tar.gz approach?
re-v yes, I have.
* mysqladmin does not work if the server isn't running already.
Start the server with ./safe_mysqld --user=root, then you can use the services of mysqladmin.
The above root is NOT the same as Linux machine root, but the default owner of the MySQL server. The name "root" is just a coincidence. Guess it's MySQL AB's contribution to the end-user's confusion :)
* IIRC, if you change passwords on a running server and then you must tell MySQL to reload privileges.
./mysqladmin --user=user_name -pyour_password flush-privileges
hope these links help -
-- 2.2.7 Installing a MySQL Binary Distribution (http://www.mysql.com/documentation/mysql/bychapter/manual_Installing.html#Installing_binary)
-- 4.8.3 mysqladmin, Administrating a MySQL Server (http://www.mysql.com/doc/en/mysqladmin.html)
hth
theN
Starts but I get the foloowing error immediately
The error is in mysql/data/localhost.localdomain.err
can't run as 'ser=root' Please check the user exists.
./bin/safe_mysqld -u=root gives the same error
'Please check that user exists
Thanks for your response
re-v