LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Having issues running mysql from command line (https://www.linuxquestions.org/questions/linux-server-73/having-issues-running-mysql-from-command-line-918627/)

Darth_Krodak 12-13-2011 11:50 PM

Having issues running mysql from command line
 
Hey I'm trying to set up a website using a a remote web server, I'm using CemtOS 5 and I haven't yet set up the GUI so I'm using command line and I was wondering how to run a .sql file through command line

I already tried imputing the command:

mysql -u Username -p DBname < program.sql

I keep on receiving a prompt saying "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)"

any suggestions

powerxcat 12-14-2011 12:14 AM

Did you start your MySQL service??

Darth_Krodak 12-14-2011 12:23 AM

yea sorry I'm a complete newb. I havent started mysql service, how would I go about doing that and would it fix the problem

powerxcat 12-14-2011 12:29 AM

Please try this command:
Code:

service mysqld start

Darth_Krodak 12-14-2011 12:51 AM

I got

-bash: service: command not found

powerxcat 12-14-2011 01:04 AM

Please try
Code:

yum install initscripts
yum install mysql*


Darth_Krodak 12-14-2011 01:11 AM

I tried both commands the 1st one told me I already had it installed and up to date, the second one just installed on the machine, What do I do now?

powerxcat 12-14-2011 03:44 AM

Code:

/etc/init.d/mysqld start
If its work, you can run your command:
Code:

mysql -u Username -p DBname < program.sql
The username should be root.

Darth_Krodak 12-14-2011 10:15 AM

When I ran the first code it said "Starting MySQL:" When I attempted to run the second code (as root) I recieved "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)"

powerxcat 12-14-2011 11:53 PM

By default, the password for root is blank.

John VV 12-15-2011 03:26 AM

it has been a bit but i thought that MySQL used the default install settings of
username : root
password: password

think of setting up a LAMP stack as a collage class with a pass/fail a 4.0 or 1
you MUST get a 4.0

so a bit of studying is REQUIRED
the Apache dosc are EXTENSIVE and so is the mysql doc pages
a few THROUGH read through are a VERY good idea

Apache
http://httpd.apache.org/docs/2.2/
mysql
http://dev.mysql.com/doc/
http://dev.mysql.com/doc/mysql-linux...tallation.html

linuxrndblog 12-15-2011 03:58 AM

Dear Darth,

Have u set the root password of mysql after installing it? If no so don't pass the option -p in command.

mysql -u root DBname < program.sql

and for mysql login/console/prompt just type mysql adn hit enter key.

i.e. [root@XLSGOPCP ~]# mysql

powerxcat said right.....By default, the password for mysql root is blank.

Darth_Krodak 12-15-2011 05:07 PM

Hey powerxcat that fixed the issue, I appreciate it

linuxrndblog 12-16-2011 02:18 AM

Dear Darth,

Great..........


All times are GMT -5. The time now is 04:40 PM.