Académique Documents
Professionnel Documents
Culture Documents
1) If you want to access mysql database remotely, you should have a Static IP so that
you can access it while adding your IP address to mysql user.
2) All Servers block port 3306 inbound request, you need to allow the port number to
particular IP on your server.
1) What is localhost ?
Localhost is a reserved address that a computer or device can use when referencing
itself.
Now, i’m going to access the mysql database from MySQL Workbench from my PC
and see what will happen.
Configuration is are below:
Connection Name : 2daygeek-demo-db (Name of this connection)
Connection Method : Standard (TCP/IP)
Parameters:
Host Name : 83.170.96.101 (Server IP Address)
Port : 3306 (mysql access port)
User Name : demou (Database Name which you want to connect)
Password : ******* (store your database password)
When i access the database, i got below error message but i have given correct
required details.
The output is clearly shows, demou user will be accessible locally(inside the server)
and not for outside (remotely). I’m going to give a remote access to my static IP. See
the below output.
6) Assigning privilege to user ?
Use the below command to enable remote access which you want.
Whatever the permission which you assign to database you should flush the
privileges.
Now, i’m going to check whether the IP address is added or not to particular user.
I’m going to access the database once again via MySQL Workbench. Now its got
successes. See the output below.
We are preparing all articles in-depth to understand by all level/stage Linux
administrators. If the article is useful for you, then please spend less than a minute to
share your valuable comments in our commenting section.
About MySQL
MySQL is an open source database management software that helps users store,
organize, and later retrieve data. It has a variety of options to grant specific users
nuanced permissions within the tables and databases—this tutorial will give a short
overview of a few of the many options.
Sadly, at this point newuser has no permissions to do anything with the databases. In
fact, if newuser even tries to login (with the password, password), they will not be able
to reach the MySQL shell.
Therefore, the first thing to do is to provide the user with access to the information they
will need.
The asterisks in this command refer to the database and table (respectively) that they
can access—this specific command allows to the user to read, edit, execute and
perform all tasks across all the databases and tables.
Once you have finalized the permissions that you want to set up for your new users,
always be sure to reload all the privileges.
FLUSH PRIVILEGES;
If you want to give them access to any database or to any table, make sure to put an
asterisk (*) in the place of the database name or table name.
Each time you update or change a permission be sure to use the Flush Privileges
command.
If you need to revoke a permission, the structure is almost identical to granting it:
Just as you can delete databases with DROP, you can use DROP to delete a user
altogether:
quit
mysql -u [username]-p
------------
Allow Remote Ronnections Acess to MySQL Server
Posted by Nikesh Jauhari
MySQL by default allows you to connect to it via localhost, you can not connect to MySQL
server directly from some remote IP address.
To enable remote mysql access you just need to perform a little editing in the mysql
configuration file. Open the mysql configuration file -- /etc/mysql/my.cnf and look for line
bind-address = 127.0.0.1
Change the above line (Comment out) with following and save the changes
#bind-address = 127.0.0.1
mysql -u root -p
On successfull login, you will need to grant rights to a user so that the user has rights to perform
DB activities from some IP address other than the server where your database is hosted
(localhost).
Good Code:
mysql sintax for insert a new row in middle rows or wherever we want without updating the
existing row, but automatically increment the primary key (id)?
' id | value
' 1 | 100
' 2 | 200
' 3 | 400
' 4 | 500
I want to insert a new row after id 2, with a value = 300. I want the output as below:
' id | value
' 1 | 100
' 2 | 200
' 3 | 300 <-- new row with id (automatic increment)
' 4 | 400 <-- id=id+1
' 5 | 500 <-- id=id+1
START TRANSACTION;
COMMIT;
Notice that you need the order by in the update statement, so it will start with the highest
ids first.
Another idea would be to declare id as decimal(10,1) and insert value 2.5 as id in between
2 and 3.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
First off, have you ensured that all of your HTML or PHP files are saved in UTF-8 format without
BOM (byte order mark)?
You also have to make sure that your server is sending a UTF-8 header in the response headers. I
think (not sure) that ASO's default setup does that, but you will want to examine your response
headers either in your browser (use Firefox Inspector if you are using Firefox) to make sure you are
or verify using a web header viewer. The response header character set declaration is much more
important than doing it in the HTML (it is a good idea to do both). If you are not sending a UTF-8
character encoding in the response header, you can do that using PHP's header() function or in
htaccess.
AddDefaultCharset UTF-8
Make sure your MySQL server connection collation is set to UTF-8 (I think it should be by default on
ASO). Then for every text field inside your database tables ensure the collation/chacter set is set to
UTF-8. If you have mangled text inside your database, you will have mangled output. Take a quick
look at it using phpMyAdmin and see if you have character problems. If you do, you may have to re-
import your data or find a way to convert it.
Now that we got that out of the way, make sure you run a "SET NAMES" query before you run any
other queries (not tested).
PHP recommends using the mysql_set_charset() function to set the character set instead of a SET
NAMES query, but since you are doing things the old way it really doesn't matter.
That last step running the SET NAMES query you may want to try first if you know you are doing
everything else mentioned above.
The mysql extension has been deprecated in PHP 5.5 in favor of the "improved" mysqli
extension. You should start writing your code to use mysqli in the future.
That's about all I am aware of. There's quite a bit to do to use UTF-8 properly.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1. MySQL
2. The Old Way
3. FULL TEXT
4. Relevancy
MySQL
This tutorial assumes a basic understanding of PHP and MySQL. Please read the MySQL
tutorial.
Prior to MySQL version 5.6, FULL TEXT searches could only be performed on MyISAM
tables, however, with the advent of 5.6 and creater, InnoDB tables can also be searched.
In MySQL 5.6, FULL TEXT seaches may be performed on CHAR, VARCHAR, and TEXT
fields.
Previously, searches in MySQL were performed using the LIKE operator. Queries like this:
SELECT id, title, body FROM tutorials WHERE title LIKE '%keyword%' OR body LIKE '%keyword%';
Whilst this method of searching records works, several problems arise. If the keyword is too
generic, far too many results are returned. There is also no way of determining th e relevency of
the returned results, and perhaps the greatest problem, is that the query is slow as it uses string
comparisons on every record title and body. As the database grows, the query will become
slower and slower.
FULL TEXT
Our simple table above has a unique identifier with the primary key index. For FULL TEXT
searching, a FULL TEXT INDEX needs to be applied to the fields which needs to searched.
We begin the FULL TEXT search by adding FULL TEXT indexes to the fields that will be
searched. In this case, the title and body fields.
With the FULLTEXT index in place, a query can now be created to search.
SELECT id, title, body FROM tutorials WHERE MATCH(title, body) AGAINST ('keyword')
Now the search will match the title and body fields against the text 'keyword'.
Relevancy
The above query correct retrieves the required results, however, in most instances, the top
scoring results are required.
SELECT
id, title, body, MATCH(title, body)
AGAINST ('keyword') `AS score
FROM tutorials
WHERE MATCH(title, body) AGAINST('keyword')
ORDER BY score DESC;
The search now scores each result, and returns the score ORDERed by relevancy. Enjoy
It is nice to be able to pass a parameter in a URL query string. However, you are not limited to
one parameter per URL; you can pass a lot of them at once. You concatenate parameters using
an ampersand (&). Concatenated URL parameters in a query string look like this:
SomeActionPage.cfm?param1=value1¶m2=value2¶m3=value3
That should help you get a good start in working with FORM and URL variables in ColdFusion.
My new book, Core ColdFusion 5, contains a complete e-commerce site, best practices, help on
finding a ColdFusion job, and much more information on using variables in ColdFusion,
including complex data types. Pick up a copy today to find out more.
$contents = file_get_contents($NameBook);